* xmlXPathCacheNewCString: * @ctxt: the XPath context * @val: the char * value * * This is the cached version of xmlXPathNewCString(). * Acquire an xmlXPathObjectPtr of type string and of value @val * * Returns the created or reused object. */
| 2071 | * Returns the created or reused object. |
| 2072 | */ |
| 2073 | static xmlXPathObjectPtr |
| 2074 | xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val) |
| 2075 | { |
| 2076 | if ((ctxt != NULL) && (ctxt->cache)) { |
| 2077 | xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; |
| 2078 | |
| 2079 | if ((cache->stringObjs != NULL) && |
| 2080 | (cache->stringObjs->number != 0)) |
| 2081 | { |
| 2082 | xmlXPathObjectPtr ret; |
| 2083 | |
| 2084 | ret = (xmlXPathObjectPtr) |
| 2085 | cache->stringObjs->items[--cache->stringObjs->number]; |
| 2086 | |
| 2087 | ret->type = XPATH_STRING; |
| 2088 | ret->stringval = xmlStrdup(BAD_CAST val); |
| 2089 | #ifdef XP_DEBUG_OBJ_USAGE |
| 2090 | xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); |
| 2091 | #endif |
| 2092 | return(ret); |
| 2093 | } else if ((cache->miscObjs != NULL) && |
| 2094 | (cache->miscObjs->number != 0)) |
| 2095 | { |
| 2096 | xmlXPathObjectPtr ret; |
| 2097 | |
| 2098 | ret = (xmlXPathObjectPtr) |
| 2099 | cache->miscObjs->items[--cache->miscObjs->number]; |
| 2100 | |
| 2101 | ret->type = XPATH_STRING; |
| 2102 | ret->stringval = xmlStrdup(BAD_CAST val); |
| 2103 | #ifdef XP_DEBUG_OBJ_USAGE |
| 2104 | xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING); |
| 2105 | #endif |
| 2106 | return(ret); |
| 2107 | } |
| 2108 | } |
| 2109 | return(xmlXPathNewCString(val)); |
| 2110 | } |
| 2111 | |
| 2112 | /** |
| 2113 | * xmlXPathCacheNewString: |
no test coverage detected