* xmlTextReaderFreeDoc: * @reader: the xmlTextReaderPtr used * @cur: pointer to the document * * Free up all the structures used by a document, tree included. */
| 482 | * Free up all the structures used by a document, tree included. |
| 483 | */ |
| 484 | static void |
| 485 | xmlTextReaderFreeDoc(xmlTextReaderPtr reader, xmlDocPtr cur) { |
| 486 | xmlDtdPtr extSubset, intSubset; |
| 487 | |
| 488 | if (cur == NULL) return; |
| 489 | |
| 490 | if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) |
| 491 | xmlDeregisterNodeDefaultValue((xmlNodePtr) cur); |
| 492 | |
| 493 | /* |
| 494 | * Do this before freeing the children list to avoid ID lookups |
| 495 | */ |
| 496 | if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids); |
| 497 | cur->ids = NULL; |
| 498 | if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs); |
| 499 | cur->refs = NULL; |
| 500 | extSubset = cur->extSubset; |
| 501 | intSubset = cur->intSubset; |
| 502 | if (intSubset == extSubset) |
| 503 | extSubset = NULL; |
| 504 | if (extSubset != NULL) { |
| 505 | xmlUnlinkNode((xmlNodePtr) cur->extSubset); |
| 506 | cur->extSubset = NULL; |
| 507 | xmlFreeDtd(extSubset); |
| 508 | } |
| 509 | if (intSubset != NULL) { |
| 510 | xmlUnlinkNode((xmlNodePtr) cur->intSubset); |
| 511 | cur->intSubset = NULL; |
| 512 | xmlFreeDtd(intSubset); |
| 513 | } |
| 514 | |
| 515 | if (cur->children != NULL) xmlTextReaderFreeNodeList(reader, cur->children); |
| 516 | |
| 517 | if (cur->version != NULL) xmlFree((char *) cur->version); |
| 518 | if (cur->name != NULL) xmlFree((char *) cur->name); |
| 519 | if (cur->encoding != NULL) xmlFree((char *) cur->encoding); |
| 520 | if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs); |
| 521 | if (cur->URL != NULL) xmlFree((char *) cur->URL); |
| 522 | if (cur->dict != NULL) xmlDictFree(cur->dict); |
| 523 | |
| 524 | xmlFree(cur); |
| 525 | } |
| 526 | |
| 527 | /************************************************************************ |
| 528 | * * |
no test coverage detected