* xmlXPathCacheNewString: * @pctxt the XPath context * @val: the xmlChar * value * * This is the cached version of xmlXPathNewString(). * Acquire an xmlXPathObjectPtr of type string and of value @val * * Returns the created or reused object. */
| 1805 | * Returns the created or reused object. |
| 1806 | */ |
| 1807 | static xmlXPathObjectPtr |
| 1808 | xmlXPathCacheNewString(xmlXPathParserContextPtr pctxt, const xmlChar *val) |
| 1809 | { |
| 1810 | xmlXPathObjectPtr ret; |
| 1811 | xmlXPathContextPtr ctxt = pctxt->context; |
| 1812 | |
| 1813 | if ((ctxt != NULL) && (ctxt->cache != NULL)) { |
| 1814 | xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache; |
| 1815 | |
| 1816 | if (cache->miscObjs != NULL) { |
| 1817 | xmlChar *copy; |
| 1818 | |
| 1819 | if (val == NULL) |
| 1820 | val = BAD_CAST ""; |
| 1821 | copy = xmlStrdup(val); |
| 1822 | if (copy == NULL) { |
| 1823 | xmlXPathPErrMemory(pctxt); |
| 1824 | return(NULL); |
| 1825 | } |
| 1826 | |
| 1827 | ret = cache->miscObjs; |
| 1828 | cache->miscObjs = (void *) ret->stringval; |
| 1829 | cache->numMisc -= 1; |
| 1830 | ret->type = XPATH_STRING; |
| 1831 | ret->stringval = copy; |
| 1832 | return(ret); |
| 1833 | } |
| 1834 | } |
| 1835 | |
| 1836 | ret = xmlXPathNewString(val); |
| 1837 | if (ret == NULL) |
| 1838 | xmlXPathPErrMemory(pctxt); |
| 1839 | return(ret); |
| 1840 | } |
| 1841 | |
| 1842 | /** |
| 1843 | * xmlXPathCacheNewCString: |
no test coverage detected