MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / xmlXPathNodeSetAddUnique

Function xmlXPathNodeSetAddUnique

Externals/LibXML/xpath.c:3604–3646  ·  view source on GitHub ↗

* xmlXPathNodeSetAddUnique: * @cur: the initial node set * @val: a new xmlNodePtr * * add a new xmlNodePtr to an existing NodeSet, optimized version * when we are sure the node is not already in the set. */

Source from the content-addressed store, hash-verified

3602 * when we are sure the node is not already in the set.
3603 */
3604void
3605xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
3606 if ((cur == NULL) || (val == NULL)) return;
3607
3608#if 0
3609 if ((val->type == XML_ELEMENT_NODE) && (val->name[0] == ' '))
3610 return; /* an XSLT fake node */
3611#endif
3612
3613 /* @@ with_ns to check whether namespace nodes should be looked at @@ */
3614 /*
3615 * grow the nodeTab if needed
3616 */
3617 if (cur->nodeMax == 0) {
3618 cur->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
3619 sizeof(xmlNodePtr));
3620 if (cur->nodeTab == NULL) {
3621 xmlXPathErrMemory(NULL, "growing nodeset\n");
3622 return;
3623 }
3624 memset(cur->nodeTab, 0 ,
3625 XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
3626 cur->nodeMax = XML_NODESET_DEFAULT;
3627 } else if (cur->nodeNr == cur->nodeMax) {
3628 xmlNodePtr *temp;
3629
3630 cur->nodeMax *= 2;
3631 temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
3632 sizeof(xmlNodePtr));
3633 if (temp == NULL) {
3634 xmlXPathErrMemory(NULL, "growing nodeset\n");
3635 return;
3636 }
3637 cur->nodeTab = temp;
3638 }
3639 if (val->type == XML_NAMESPACE_DECL) {
3640 xmlNsPtr ns = (xmlNsPtr) val;
3641
3642 cur->nodeTab[cur->nodeNr++] =
3643 xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
3644 } else
3645 cur->nodeTab[cur->nodeNr++] = val;
3646}
3647
3648/**
3649 * xmlXPathNodeSetMerge:

Callers 13

xmlXPathCacheNewNodeSetFunction · 0.85
xmlXPathNewNodeSetListFunction · 0.85
xmlXPathDifferenceFunction · 0.85
xmlXPathIntersectionFunction · 0.85
xmlXPathDistinctSortedFunction · 0.85
xmlXPathCompOpEvalFunction · 0.85

Calls 3

xmlXPathErrMemoryFunction · 0.85
memsetFunction · 0.85
xmlXPathNodeSetDupNsFunction · 0.85

Tested by 1