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

Function xmlAddChild

ThirdParty/libxml2/vtklibxml2/tree.c:3401–3435  ·  view source on GitHub ↗

* xmlAddChild: * @parent: the parent node * @cur: the child node * * Unlink @cur and append it to the children of @parent. * * If @cur is a text node, it may be merged with an adjacent text * node and freed. In this case the text node containing the merged * content is returned. * * If @cur is an attribute node, it is appended to the attributes of * @parent. If the attribute list cont

Source from the content-addressed store, hash-verified

3399 * if arguments are invalid or a memory allocation failed.
3400 */
3401xmlNodePtr
3402xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
3403 xmlNodePtr prev;
3404
3405 if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL) ||
3406 (cur == NULL) || (cur->type == XML_NAMESPACE_DECL) ||
3407 (parent == cur))
3408 return(NULL);
3409
3410 /*
3411 * If parent is a text node, call xmlTextAddContent. This
3412 * undocumented quirk should probably be removed.
3413 */
3414 if (parent->type == XML_TEXT_NODE) {
3415 if (xmlTextAddContent(parent, cur->content, -1) < 0)
3416 return(NULL);
3417 xmlFreeNode(cur);
3418 return(parent);
3419 }
3420
3421 if (cur->type == XML_ATTRIBUTE_NODE) {
3422 prev = (xmlNodePtr) parent->properties;
3423 if (prev != NULL) {
3424 while (prev->next != NULL)
3425 prev = prev->next;
3426 }
3427 } else {
3428 prev = parent->last;
3429 }
3430
3431 if (cur == prev)
3432 return(cur);
3433
3434 return(xmlInsertNode(parent->doc, cur, parent, prev, NULL, 1));
3435}
3436
3437/**
3438 * xmlGetLastChild:

Callers 15

getXMLNodeMethod · 0.85
visitMethod · 0.85
xmlDumpXMLCatalogNodeFunction · 0.85
xmlDumpXMLCatalogFunction · 0.85
xmlXPathObjectCopyFunction · 0.85
xmlParseCRNG_nameClassFunction · 0.85
xmlParseCRNG_particleFunction · 0.85
xmlParseCRNG_patternFunction · 0.85
xmlParseCRNG_componentFunction · 0.85
xmlNodeAddContentLenFunction · 0.85

Calls 3

xmlTextAddContentFunction · 0.85
xmlFreeNodeFunction · 0.85
xmlInsertNodeFunction · 0.85

Tested by

no test coverage detected