* xmlFreeDoc: * @cur: pointer to the document * * Free a document including all children and associated DTDs. */
| 1134 | * Free a document including all children and associated DTDs. |
| 1135 | */ |
| 1136 | void |
| 1137 | xmlFreeDoc(xmlDocPtr cur) { |
| 1138 | xmlDtdPtr extSubset, intSubset; |
| 1139 | xmlDictPtr dict = NULL; |
| 1140 | |
| 1141 | if (cur == NULL) { |
| 1142 | return; |
| 1143 | } |
| 1144 | |
| 1145 | dict = cur->dict; |
| 1146 | |
| 1147 | if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue)) |
| 1148 | xmlDeregisterNodeDefaultValue((xmlNodePtr)cur); |
| 1149 | |
| 1150 | /* |
| 1151 | * Do this before freeing the children list to avoid ID lookups |
| 1152 | */ |
| 1153 | if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids); |
| 1154 | cur->ids = NULL; |
| 1155 | if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs); |
| 1156 | cur->refs = NULL; |
| 1157 | extSubset = cur->extSubset; |
| 1158 | intSubset = cur->intSubset; |
| 1159 | if (intSubset == extSubset) |
| 1160 | extSubset = NULL; |
| 1161 | if (extSubset != NULL) { |
| 1162 | xmlUnlinkNodeInternal((xmlNodePtr) cur->extSubset); |
| 1163 | cur->extSubset = NULL; |
| 1164 | xmlFreeDtd(extSubset); |
| 1165 | } |
| 1166 | if (intSubset != NULL) { |
| 1167 | xmlUnlinkNodeInternal((xmlNodePtr) cur->intSubset); |
| 1168 | cur->intSubset = NULL; |
| 1169 | xmlFreeDtd(intSubset); |
| 1170 | } |
| 1171 | |
| 1172 | if (cur->children != NULL) xmlFreeNodeList(cur->children); |
| 1173 | if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs); |
| 1174 | |
| 1175 | DICT_FREE(cur->version) |
| 1176 | DICT_FREE(cur->name) |
| 1177 | DICT_FREE(cur->encoding) |
| 1178 | DICT_FREE(cur->URL) |
| 1179 | xmlFree(cur); |
| 1180 | if (dict) xmlDictFree(dict); |
| 1181 | } |
| 1182 | |
| 1183 | /** |
| 1184 | * xmlNodeParseContentInternal: |