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

Function xmlFreeNodeList

ThirdParty/libxml2/vtklibxml2/tree.c:3646–3726  ·  view source on GitHub ↗

* xmlFreeNodeList: * @cur: the first node in the list * * Free a node list including all children. */

Source from the content-addressed store, hash-verified

3644 * Free a node list including all children.
3645 */
3646void
3647xmlFreeNodeList(xmlNodePtr cur) {
3648 xmlNodePtr next;
3649 xmlNodePtr parent;
3650 xmlDictPtr dict = NULL;
3651 size_t depth = 0;
3652
3653 if (cur == NULL) return;
3654 if (cur->type == XML_NAMESPACE_DECL) {
3655 xmlFreeNsList((xmlNsPtr) cur);
3656 return;
3657 }
3658 if (cur->doc != NULL) dict = cur->doc->dict;
3659 while (1) {
3660 while ((cur->children != NULL) &&
3661 (cur->type != XML_DOCUMENT_NODE) &&
3662 (cur->type != XML_HTML_DOCUMENT_NODE) &&
3663 (cur->type != XML_DTD_NODE) &&
3664 (cur->type != XML_ENTITY_REF_NODE)) {
3665 cur = cur->children;
3666 depth += 1;
3667 }
3668
3669 next = cur->next;
3670 parent = cur->parent;
3671 if ((cur->type == XML_DOCUMENT_NODE) ||
3672 (cur->type == XML_HTML_DOCUMENT_NODE)) {
3673 xmlFreeDoc((xmlDocPtr) cur);
3674 } else if (cur->type == XML_DTD_NODE) {
3675 /*
3676 * TODO: We should consider freeing the DTD if it isn't
3677 * referenced from doc->intSubset or doc->extSubset.
3678 */
3679 cur->prev = NULL;
3680 cur->next = NULL;
3681 } else {
3682 if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
3683 xmlDeregisterNodeDefaultValue(cur);
3684
3685 if (((cur->type == XML_ELEMENT_NODE) ||
3686 (cur->type == XML_XINCLUDE_START) ||
3687 (cur->type == XML_XINCLUDE_END)) &&
3688 (cur->properties != NULL))
3689 xmlFreePropList(cur->properties);
3690 if ((cur->type != XML_ELEMENT_NODE) &&
3691 (cur->type != XML_XINCLUDE_START) &&
3692 (cur->type != XML_XINCLUDE_END) &&
3693 (cur->type != XML_ENTITY_REF_NODE) &&
3694 (cur->content != (xmlChar *) &(cur->properties))) {
3695 DICT_FREE(cur->content)
3696 }
3697 if (((cur->type == XML_ELEMENT_NODE) ||
3698 (cur->type == XML_XINCLUDE_START) ||
3699 (cur->type == XML_XINCLUDE_END)) &&
3700 (cur->nsDef != NULL))
3701 xmlFreeNsList(cur->nsDef);
3702
3703 /*

Callers 15

xmlXPathPopNodeSetFunction · 0.85
xmlFreeDocFunction · 0.85
xmlFreePropFunction · 0.85
xmlFreeNodeFunction · 0.85
xmlStaticCopyNodeListFunction · 0.85
xmlSetNsPropFunction · 0.85
xmlFreeEntityFunction · 0.85
xmlCtxtParseEntityFunction · 0.85
xmlParseInNodeContextFunction · 0.85

Calls 3

xmlFreeNsListFunction · 0.85
xmlFreeDocFunction · 0.85
xmlFreePropListFunction · 0.85

Tested by

no test coverage detected