MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathCacheNewNodeSet

Function xmlXPathCacheNewNodeSet

ThirdParty/libxml2/vtklibxml2/xpath.c:1738–1795  ·  view source on GitHub ↗

* xmlXPathCacheNewNodeSet: * @pctxt the XPath context * @val: the NodePtr value * * This is the cached version of xmlXPathNewNodeSet(). * Acquire an xmlXPathObjectPtr of type NodeSet and initialize * it with the single Node @val * * Returns the created or reused object. */

Source from the content-addressed store, hash-verified

1736 * Returns the created or reused object.
1737 */
1738static xmlXPathObjectPtr
1739xmlXPathCacheNewNodeSet(xmlXPathParserContextPtr pctxt, xmlNodePtr val)
1740{
1741 xmlXPathObjectPtr ret;
1742 xmlXPathContextPtr ctxt = pctxt->context;
1743
1744 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
1745 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
1746
1747 if (cache->nodesetObjs != NULL) {
1748 /*
1749 * Use the nodeset-cache.
1750 */
1751 ret = cache->nodesetObjs;
1752 cache->nodesetObjs = (void *) ret->stringval;
1753 cache->numNodeset -= 1;
1754 ret->stringval = NULL;
1755 ret->type = XPATH_NODESET;
1756 ret->boolval = 0;
1757 if (val) {
1758 if ((ret->nodesetval->nodeMax == 0) ||
1759 (val->type == XML_NAMESPACE_DECL))
1760 {
1761 if (xmlXPathNodeSetAddUnique(ret->nodesetval, val) < 0)
1762 xmlXPathPErrMemory(pctxt);
1763 } else {
1764 ret->nodesetval->nodeTab[0] = val;
1765 ret->nodesetval->nodeNr = 1;
1766 }
1767 }
1768 return(ret);
1769 } else if (cache->miscObjs != NULL) {
1770 xmlNodeSetPtr set;
1771 /*
1772 * Fallback to misc-cache.
1773 */
1774
1775 set = xmlXPathNodeSetCreate(val);
1776 if (set == NULL) {
1777 xmlXPathPErrMemory(pctxt);
1778 return(NULL);
1779 }
1780
1781 ret = cache->miscObjs;
1782 cache->miscObjs = (void *) ret->stringval;
1783 cache->numMisc -= 1;
1784 ret->stringval = NULL;
1785 ret->type = XPATH_NODESET;
1786 ret->boolval = 0;
1787 ret->nodesetval = set;
1788 return(ret);
1789 }
1790 }
1791 ret = xmlXPathNewNodeSet(val);
1792 if (ret == NULL)
1793 xmlXPathPErrMemory(pctxt);
1794 return(ret);
1795}

Callers 8

xmlXPathRootFunction · 0.85
xmlXPathNameFunctionFunction · 0.85
xmlXPathCompOpEvalFirstFunction · 0.85
xmlXPathCompOpEvalLastFunction · 0.85
xmlXPathCompOpEvalFunction · 0.85
xmlXPathRunStreamEvalFunction · 0.85

Calls 4

xmlXPathNodeSetAddUniqueFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85
xmlXPathNodeSetCreateFunction · 0.85
xmlXPathNewNodeSetFunction · 0.85

Tested by

no test coverage detected