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

Function xmlXPtrLocationSetAdd

ThirdParty/libxml2/vtklibxml2/xpointer.c:607–649  ·  view source on GitHub ↗

* xmlXPtrLocationSetAdd: * @cur: the initial range set * @val: a new xmlXPathObjectPtr * * add a new xmlXPathObjectPtr to an existing LocationSet * If the location already exist in the set @val is freed. */

Source from the content-addressed store, hash-verified

605 * If the location already exist in the set @val is freed.
606 */
607void
608xmlXPtrLocationSetAdd(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
609 int i;
610
611 if ((cur == NULL) || (val == NULL)) return;
612
613 /*
614 * check against doublons
615 */
616 for (i = 0;i < cur->locNr;i++) {
617 if (xmlXPtrRangesEqual(cur->locTab[i], val)) {
618 xmlXPathFreeObject(val);
619 return;
620 }
621 }
622
623 /*
624 * grow the locTab if needed
625 */
626 if (cur->locMax == 0) {
627 cur->locTab = (xmlXPathObjectPtr *) xmlMalloc(XML_RANGESET_DEFAULT *
628 sizeof(xmlXPathObjectPtr));
629 if (cur->locTab == NULL) {
630 xmlXPtrErrMemory("adding location to set");
631 return;
632 }
633 memset(cur->locTab, 0 ,
634 XML_RANGESET_DEFAULT * sizeof(xmlXPathObjectPtr));
635 cur->locMax = XML_RANGESET_DEFAULT;
636 } else if (cur->locNr == cur->locMax) {
637 xmlXPathObjectPtr *temp;
638
639 cur->locMax *= 2;
640 temp = (xmlXPathObjectPtr *) xmlRealloc(cur->locTab, cur->locMax *
641 sizeof(xmlXPathObjectPtr));
642 if (temp == NULL) {
643 xmlXPtrErrMemory("adding location to set");
644 return;
645 }
646 cur->locTab = temp;
647 }
648 cur->locTab[cur->locNr++] = val;
649}
650
651/**
652 * xmlXPtrLocationSetMerge:

Callers 8

xmlXPtrLocationSetMergeFunction · 0.70
xmlXPtrEndPointFunctionFunction · 0.70
xmlXPtrRangeFunctionFunction · 0.70

Calls 3

xmlXPtrRangesEqualFunction · 0.85
xmlXPathFreeObjectFunction · 0.85
xmlXPtrErrMemoryFunction · 0.85

Tested by

no test coverage detected