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

Function xmlXPathObjectCopy

ThirdParty/libxml2/vtklibxml2/xpath.c:4449–4534  ·  view source on GitHub ↗

* xmlXPathObjectCopy: * @val: the original object * * allocate a new copy of a given object * * Returns the newly created object. */

Source from the content-addressed store, hash-verified

4447 * Returns the newly created object.
4448 */
4449xmlXPathObjectPtr
4450xmlXPathObjectCopy(xmlXPathObjectPtr val) {
4451 xmlXPathObjectPtr ret;
4452
4453 if (val == NULL)
4454 return(NULL);
4455
4456 ret = (xmlXPathObjectPtr) xmlMalloc(sizeof(xmlXPathObject));
4457 if (ret == NULL)
4458 return(NULL);
4459 memcpy(ret, val , sizeof(xmlXPathObject));
4460 switch (val->type) {
4461 case XPATH_BOOLEAN:
4462 case XPATH_NUMBER:
4463#ifdef LIBXML_XPTR_LOCS_ENABLED
4464 case XPATH_POINT:
4465 case XPATH_RANGE:
4466#endif /* LIBXML_XPTR_LOCS_ENABLED */
4467 break;
4468 case XPATH_STRING:
4469 ret->stringval = xmlStrdup(val->stringval);
4470 if (ret->stringval == NULL) {
4471 xmlFree(ret);
4472 return(NULL);
4473 }
4474 break;
4475 case XPATH_XSLT_TREE:
4476#if 0
4477/*
4478 Removed 11 July 2004 - the current handling of xslt tmpRVT nodes means that
4479 this previous handling is no longer correct, and can cause some serious
4480 problems (ref. bug 145547)
4481*/
4482 if ((val->nodesetval != NULL) &&
4483 (val->nodesetval->nodeTab != NULL)) {
4484 xmlNodePtr cur, tmp;
4485 xmlDocPtr top;
4486
4487 ret->boolval = 1;
4488 top = xmlNewDoc(NULL);
4489 top->name = (char *)
4490 xmlStrdup(val->nodesetval->nodeTab[0]->name);
4491 ret->user = top;
4492 if (top != NULL) {
4493 top->doc = top;
4494 cur = val->nodesetval->nodeTab[0]->children;
4495 while (cur != NULL) {
4496 tmp = xmlDocCopyNode(cur, top, 1);
4497 xmlAddChild((xmlNodePtr) top, tmp);
4498 cur = cur->next;
4499 }
4500 }
4501
4502 ret->nodesetval = xmlXPathNodeSetCreate((xmlNodePtr) top);
4503 } else
4504 ret->nodesetval = xmlXPathNodeSetCreate(NULL);
4505 /* Deallocate the copied tree value */
4506 break;

Callers 3

xmlXPathCacheObjectCopyFunction · 0.85
xmlXPathVariableLookupNSFunction · 0.85

Calls 7

xmlStrdupFunction · 0.85
xmlNewDocFunction · 0.85
xmlDocCopyNodeFunction · 0.85
xmlAddChildFunction · 0.85
xmlXPathNodeSetCreateFunction · 0.85
xmlXPathNodeSetMergeFunction · 0.85
xmlXPtrLocationSetMergeFunction · 0.70

Tested by

no test coverage detected