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

Function xmlAddSibling

ThirdParty/libxml2/vtklibxml2/tree.c:3256–3279  ·  view source on GitHub ↗

* xmlAddSibling: * @node: the target node * @cur: the new node * * Unlinks @cur and inserts it as last sibling of @node. * * 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 attribute * list containing @node. If the attribute l

Source from the content-addressed store, hash-verified

3254 * if arguments are invalid or a memory allocation failed.
3255 */
3256xmlNodePtr
3257xmlAddSibling(xmlNodePtr node, xmlNodePtr cur) {
3258 if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
3259 (cur == NULL) || (cur->type == XML_NAMESPACE_DECL) ||
3260 (cur == node))
3261 return(NULL);
3262
3263 /*
3264 * Constant time is we can rely on the ->parent->last to find
3265 * the last sibling.
3266 */
3267 if ((node->type != XML_ATTRIBUTE_NODE) && (node->parent != NULL)) {
3268 if (node->parent->last != NULL)
3269 node = node->parent->last;
3270 } else {
3271 while (node->next != NULL)
3272 node = node->next;
3273 }
3274
3275 if (cur == node)
3276 return(cur);
3277
3278 return(xmlInsertNode(node->doc, cur, node->parent, node, NULL, 1));
3279}
3280
3281/**
3282 * xmlAddChildList:

Callers 1

xmlDocSetRootElementFunction · 0.85

Calls 1

xmlInsertNodeFunction · 0.85

Tested by

no test coverage detected