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

Function xmlXPathReleaseObject

ThirdParty/libxml2/vtklibxml2/xpath.c:4572–4663  ·  view source on GitHub ↗

* xmlXPathReleaseObject: * @obj: the xmlXPathObjectPtr to free or to cache * * Depending on the state of the cache this frees the given * XPath object or stores it in the cache. */

Source from the content-addressed store, hash-verified

4570 * XPath object or stores it in the cache.
4571 */
4572static void
4573xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
4574{
4575 if (obj == NULL)
4576 return;
4577 if ((ctxt == NULL) || (ctxt->cache == NULL)) {
4578 xmlXPathFreeObject(obj);
4579 } else {
4580 xmlXPathContextCachePtr cache =
4581 (xmlXPathContextCachePtr) ctxt->cache;
4582
4583 switch (obj->type) {
4584 case XPATH_NODESET:
4585 case XPATH_XSLT_TREE:
4586 if (obj->nodesetval != NULL) {
4587 if ((obj->nodesetval->nodeMax <= 40) &&
4588 (cache->numNodeset < cache->maxNodeset)) {
4589 obj->stringval = (void *) cache->nodesetObjs;
4590 cache->nodesetObjs = obj;
4591 cache->numNodeset += 1;
4592 goto obj_cached;
4593 } else {
4594 xmlXPathFreeNodeSet(obj->nodesetval);
4595 obj->nodesetval = NULL;
4596 }
4597 }
4598 break;
4599 case XPATH_STRING:
4600 if (obj->stringval != NULL)
4601 xmlFree(obj->stringval);
4602 obj->stringval = NULL;
4603 break;
4604 case XPATH_BOOLEAN:
4605 case XPATH_NUMBER:
4606 break;
4607#ifdef LIBXML_XPTR_LOCS_ENABLED
4608 case XPATH_LOCATIONSET:
4609 if (obj->user != NULL) {
4610 xmlXPtrFreeLocationSet(obj->user);
4611 }
4612 goto free_obj;
4613#endif
4614 default:
4615 goto free_obj;
4616 }
4617
4618 /*
4619 * Fallback to adding to the misc-objects slot.
4620 */
4621 if (cache->numMisc >= cache->maxMisc)
4622 goto free_obj;
4623 obj->stringval = (void *) cache->miscObjs;
4624 cache->miscObjs = obj;
4625 cache->numMisc += 1;
4626
4627obj_cached:
4628 obj->boolval = 0;
4629 if (obj->nodesetval != NULL) {

Callers 15

xmlXPathPopBooleanFunction · 0.85
xmlXPathPopNumberFunction · 0.85
xmlXPathPopStringFunction · 0.85
xmlXPathPopNodeSetFunction · 0.85
xmlXPathPopExternalFunction · 0.85
xmlXPathEqualValuesFunction · 0.85

Calls 4

xmlXPathFreeObjectFunction · 0.85
xmlXPathFreeNodeSetFunction · 0.85
xmlXPathNodeSetFreeNsFunction · 0.85
xmlXPtrFreeLocationSetFunction · 0.70

Tested by

no test coverage detected