* xmlFreeNode: * @cur: the node * * Free a node including all the children. * * This doesn't unlink the node from the tree. Call xmlUnlinkNode first * unless @cur is a root node. */
| 3735 | * unless @cur is a root node. |
| 3736 | */ |
| 3737 | void |
| 3738 | xmlFreeNode(xmlNodePtr cur) { |
| 3739 | xmlDictPtr dict = NULL; |
| 3740 | |
| 3741 | if (cur == NULL) return; |
| 3742 | |
| 3743 | /* use xmlFreeDtd for DTD nodes */ |
| 3744 | if (cur->type == XML_DTD_NODE) { |
| 3745 | xmlFreeDtd((xmlDtdPtr) cur); |
| 3746 | return; |
| 3747 | } |
| 3748 | if (cur->type == XML_NAMESPACE_DECL) { |
| 3749 | xmlFreeNs((xmlNsPtr) cur); |
| 3750 | return; |
| 3751 | } |
| 3752 | if (cur->type == XML_ATTRIBUTE_NODE) { |
| 3753 | xmlFreeProp((xmlAttrPtr) cur); |
| 3754 | return; |
| 3755 | } |
| 3756 | if (cur->type == XML_ENTITY_DECL) { |
| 3757 | xmlFreeEntity((xmlEntityPtr) cur); |
| 3758 | return; |
| 3759 | } |
| 3760 | |
| 3761 | if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) |
| 3762 | xmlDeregisterNodeDefaultValue(cur); |
| 3763 | |
| 3764 | if (cur->doc != NULL) dict = cur->doc->dict; |
| 3765 | |
| 3766 | if ((cur->children != NULL) && |
| 3767 | (cur->type != XML_ENTITY_REF_NODE)) |
| 3768 | xmlFreeNodeList(cur->children); |
| 3769 | |
| 3770 | if ((cur->type == XML_ELEMENT_NODE) || |
| 3771 | (cur->type == XML_XINCLUDE_START) || |
| 3772 | (cur->type == XML_XINCLUDE_END)) { |
| 3773 | if (cur->properties != NULL) |
| 3774 | xmlFreePropList(cur->properties); |
| 3775 | if (cur->nsDef != NULL) |
| 3776 | xmlFreeNsList(cur->nsDef); |
| 3777 | } else if ((cur->content != NULL) && |
| 3778 | (cur->type != XML_ENTITY_REF_NODE) && |
| 3779 | (cur->content != (xmlChar *) &(cur->properties))) { |
| 3780 | DICT_FREE(cur->content) |
| 3781 | } |
| 3782 | |
| 3783 | /* |
| 3784 | * When a node is a text node or a comment, it uses a global static |
| 3785 | * variable for the name of the node. |
| 3786 | * Otherwise the node name might come from the document's dictionary |
| 3787 | */ |
| 3788 | if ((cur->name != NULL) && |
| 3789 | (cur->type != XML_TEXT_NODE) && |
| 3790 | (cur->type != XML_COMMENT_NODE)) |
| 3791 | DICT_FREE(cur->name) |
| 3792 | |
| 3793 | xmlFree(cur); |
| 3794 | } |
no test coverage detected