* xmlTextReaderFreeNode: * @reader: the xmlTextReaderPtr used * @cur: the node * * Free a node, this is a recursive behaviour, all the children are freed too. * This doesn't unlink the child from the list, use xmlUnlinkNode() first. */
| 407 | * This doesn't unlink the child from the list, use xmlUnlinkNode() first. |
| 408 | */ |
| 409 | static void |
| 410 | xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) { |
| 411 | xmlDictPtr dict; |
| 412 | |
| 413 | if ((reader != NULL) && (reader->ctxt != NULL)) |
| 414 | dict = reader->ctxt->dict; |
| 415 | else |
| 416 | dict = NULL; |
| 417 | if (cur->type == XML_DTD_NODE) { |
| 418 | xmlFreeDtd((xmlDtdPtr) cur); |
| 419 | return; |
| 420 | } |
| 421 | if (cur->type == XML_NAMESPACE_DECL) { |
| 422 | xmlFreeNs((xmlNsPtr) cur); |
| 423 | return; |
| 424 | } |
| 425 | if (cur->type == XML_ATTRIBUTE_NODE) { |
| 426 | xmlTextReaderFreeProp(reader, (xmlAttrPtr) cur); |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | if ((cur->children != NULL) && |
| 431 | (cur->type != XML_ENTITY_REF_NODE)) { |
| 432 | if (cur->children->parent == cur) |
| 433 | xmlTextReaderFreeNodeList(reader, cur->children); |
| 434 | cur->children = NULL; |
| 435 | } |
| 436 | |
| 437 | if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) |
| 438 | xmlDeregisterNodeDefaultValue(cur); |
| 439 | |
| 440 | if (((cur->type == XML_ELEMENT_NODE) || |
| 441 | (cur->type == XML_XINCLUDE_START) || |
| 442 | (cur->type == XML_XINCLUDE_END)) && |
| 443 | (cur->properties != NULL)) |
| 444 | xmlTextReaderFreePropList(reader, cur->properties); |
| 445 | if ((cur->content != (xmlChar *) &(cur->properties)) && |
| 446 | (cur->type != XML_ELEMENT_NODE) && |
| 447 | (cur->type != XML_XINCLUDE_START) && |
| 448 | (cur->type != XML_XINCLUDE_END) && |
| 449 | (cur->type != XML_ENTITY_REF_NODE)) { |
| 450 | DICT_FREE(cur->content); |
| 451 | } |
| 452 | if (((cur->type == XML_ELEMENT_NODE) || |
| 453 | (cur->type == XML_XINCLUDE_START) || |
| 454 | (cur->type == XML_XINCLUDE_END)) && |
| 455 | (cur->nsDef != NULL)) |
| 456 | xmlFreeNsList(cur->nsDef); |
| 457 | |
| 458 | /* |
| 459 | * we don't free names here they are interned now |
| 460 | */ |
| 461 | if ((cur->type != XML_TEXT_NODE) && |
| 462 | (cur->type != XML_COMMENT_NODE)) |
| 463 | DICT_FREE(cur->name); |
| 464 | |
| 465 | if (((cur->type == XML_ELEMENT_NODE) || |
| 466 | (cur->type == XML_TEXT_NODE)) && |
no test coverage detected