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

Function xmlTextReaderFreeNodeList

ThirdParty/libxml2/vtklibxml2/xmlreader.c:314–399  ·  view source on GitHub ↗

* xmlTextReaderFreeNodeList: * @reader: the xmlTextReaderPtr used * @cur: the first node in the list * * Free a node and all its siblings, this is a recursive behaviour, all * the children are freed too. */

Source from the content-addressed store, hash-verified

312 * the children are freed too.
313 */
314static void
315xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
316 xmlNodePtr next;
317 xmlNodePtr parent;
318 xmlDictPtr dict;
319 size_t depth = 0;
320
321 if ((reader != NULL) && (reader->ctxt != NULL))
322 dict = reader->ctxt->dict;
323 else
324 dict = NULL;
325 if (cur == NULL) return;
326 if (cur->type == XML_NAMESPACE_DECL) {
327 xmlFreeNsList((xmlNsPtr) cur);
328 return;
329 }
330 if ((cur->type == XML_DOCUMENT_NODE) ||
331 (cur->type == XML_HTML_DOCUMENT_NODE)) {
332 xmlFreeDoc((xmlDocPtr) cur);
333 return;
334 }
335 while (1) {
336 while ((cur->type != XML_DTD_NODE) &&
337 (cur->type != XML_ENTITY_REF_NODE) &&
338 (cur->children != NULL) &&
339 (cur->children->parent == cur)) {
340 cur = cur->children;
341 depth += 1;
342 }
343
344 next = cur->next;
345 parent = cur->parent;
346
347 /* unroll to speed up freeing the document */
348 if (cur->type != XML_DTD_NODE) {
349
350 if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
351 xmlDeregisterNodeDefaultValue(cur);
352
353 if (((cur->type == XML_ELEMENT_NODE) ||
354 (cur->type == XML_XINCLUDE_START) ||
355 (cur->type == XML_XINCLUDE_END)) &&
356 (cur->properties != NULL))
357 xmlTextReaderFreePropList(reader, cur->properties);
358 if ((cur->content != (xmlChar *) &(cur->properties)) &&
359 (cur->type != XML_ELEMENT_NODE) &&
360 (cur->type != XML_XINCLUDE_START) &&
361 (cur->type != XML_XINCLUDE_END) &&
362 (cur->type != XML_ENTITY_REF_NODE)) {
363 DICT_FREE(cur->content);
364 }
365 if (((cur->type == XML_ELEMENT_NODE) ||
366 (cur->type == XML_XINCLUDE_START) ||
367 (cur->type == XML_XINCLUDE_END)) &&
368 (cur->nsDef != NULL))
369 xmlFreeNsList(cur->nsDef);
370
371 /*

Callers 3

xmlTextReaderFreePropFunction · 0.85
xmlTextReaderFreeNodeFunction · 0.85
xmlTextReaderFreeDocFunction · 0.85

Calls 3

xmlFreeNsListFunction · 0.85
xmlFreeDocFunction · 0.85

Tested by

no test coverage detected