* xmlXPathCacheWrapNodeSet: * @pctxt: the XPath context * @val: the NodePtr value * * This is the cached version of xmlXPathWrapNodeSet(). * Wrap the Nodeset @val in a new xmlXPathObjectPtr * * Returns the created or reused object. * * In case of error the node set is destroyed and NULL is returned. */
| 1663 | * In case of error the node set is destroyed and NULL is returned. |
| 1664 | */ |
| 1665 | static xmlXPathObjectPtr |
| 1666 | xmlXPathCacheWrapNodeSet(xmlXPathParserContextPtr pctxt, xmlNodeSetPtr val) |
| 1667 | { |
| 1668 | xmlXPathObjectPtr ret; |
| 1669 | xmlXPathContextPtr ctxt = pctxt->context; |
| 1670 | |
| 1671 | if ((ctxt != NULL) && (ctxt->cache != NULL)) { |
| 1672 | xmlXPathContextCachePtr cache = |
| 1673 | (xmlXPathContextCachePtr) ctxt->cache; |
| 1674 | |
| 1675 | if (cache->miscObjs != NULL) { |
| 1676 | ret = cache->miscObjs; |
| 1677 | cache->miscObjs = (void *) ret->stringval; |
| 1678 | cache->numMisc -= 1; |
| 1679 | ret->stringval = NULL; |
| 1680 | ret->type = XPATH_NODESET; |
| 1681 | ret->nodesetval = val; |
| 1682 | return(ret); |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | ret = xmlXPathWrapNodeSet(val); |
| 1687 | if (ret == NULL) |
| 1688 | xmlXPathPErrMemory(pctxt); |
| 1689 | return(ret); |
| 1690 | } |
| 1691 | |
| 1692 | /** |
| 1693 | * xmlXPathCacheWrapString: |
no test coverage detected