mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
applied an old patch from Lukas Schroeder to track node creation and
* global.data globals.c tree.c include/libxml/globals.h: applied an old patch from Lukas Schroeder to track node creation and destruction. Probably missing a lot of references at the moment and not usable reliably. Daniel
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
Wed Jan 1 21:57:28 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* global.data globals.c tree.c include/libxml/globals.h: applied
|
||||||
|
an old patch from Lukas Schroeder to track node creation and
|
||||||
|
destruction. Probably missing a lot of references at the moment
|
||||||
|
and not usable reliably.
|
||||||
|
|
||||||
Wed Jan 1 20:12:07 CET 2003 Daniel Veillard <daniel@veillard.com>
|
Wed Jan 1 20:12:07 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* NEWS doc/Makefile.am doc/news.xsl: generate the NEWS file
|
* NEWS doc/Makefile.am doc/news.xsl: generate the NEWS file
|
||||||
|
@@ -20,3 +20,5 @@ int,xmlSaveNoEmptyTags
|
|||||||
#const xmlChar,xmlStringText,[]
|
#const xmlChar,xmlStringText,[]
|
||||||
#const xmlChar,xmlStringTextNoenc,[]
|
#const xmlChar,xmlStringTextNoenc,[]
|
||||||
int,xmlSubstituteEntitiesDefaultValue
|
int,xmlSubstituteEntitiesDefaultValue
|
||||||
|
xmlRegisterNodeFunc,xmlRegisterNodeDefaultValue
|
||||||
|
xmlDeregisterNodeFunc,xmlDeregisterNodeDefaultValue
|
||||||
|
53
globals.c
53
globals.c
@@ -219,6 +219,9 @@ int xmlKeepBlanksDefaultValue = 1;
|
|||||||
*/
|
*/
|
||||||
int xmlSubstituteEntitiesDefaultValue = 0;
|
int xmlSubstituteEntitiesDefaultValue = 0;
|
||||||
|
|
||||||
|
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue = NULL;
|
||||||
|
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Error handling
|
* Error handling
|
||||||
*/
|
*/
|
||||||
@@ -450,8 +453,40 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
|||||||
gs->xmlPedanticParserDefaultValue = 0;
|
gs->xmlPedanticParserDefaultValue = 0;
|
||||||
gs->xmlSaveNoEmptyTags = 0;
|
gs->xmlSaveNoEmptyTags = 0;
|
||||||
gs->xmlSubstituteEntitiesDefaultValue = 0;
|
gs->xmlSubstituteEntitiesDefaultValue = 0;
|
||||||
|
|
||||||
|
gs->xmlRegisterNodeDefaultValue = NULL;
|
||||||
|
gs->xmlDeregisterNodeDefaultValue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlRegisterNodeDefault
|
||||||
|
* @func: function pointer to the new RegisterNodeFunc
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
xmlRegisterNodeFunc
|
||||||
|
xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
|
||||||
|
{
|
||||||
|
xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
|
||||||
|
|
||||||
|
xmlRegisterNodeDefaultValue = func;
|
||||||
|
return(old);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlDeegisterNodeDefault
|
||||||
|
* @func: function pointer to the new DeregisterNodeFunc
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
xmlDeregisterNodeFunc
|
||||||
|
xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
|
||||||
|
{
|
||||||
|
xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
|
||||||
|
|
||||||
|
xmlDeregisterNodeDefaultValue = func;
|
||||||
|
return(old);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef LIBXML_DOCB_ENABLED
|
#ifdef LIBXML_DOCB_ENABLED
|
||||||
#undef docbDefaultSAXHandler
|
#undef docbDefaultSAXHandler
|
||||||
xmlSAXHandler *
|
xmlSAXHandler *
|
||||||
@@ -651,3 +686,21 @@ __xmlSubstituteEntitiesDefaultValue(void) {
|
|||||||
else
|
else
|
||||||
return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
|
return (&xmlGetGlobalState()->xmlSubstituteEntitiesDefaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef xmlRegisterNodeDefaultValue
|
||||||
|
xmlRegisterNodeFunc *
|
||||||
|
__xmlRegisterNodeDefaultValue(void) {
|
||||||
|
if (IS_MAIN_THREAD)
|
||||||
|
return (&xmlRegisterNodeDefaultValue);
|
||||||
|
else
|
||||||
|
return (&xmlGetGlobalState()->xmlRegisterNodeDefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef xmlDeregisterNodeDefaultValue
|
||||||
|
xmlDeregisterNodeFunc *
|
||||||
|
__xmlDeregisterNodeDefaultValue(void) {
|
||||||
|
if (IS_MAIN_THREAD)
|
||||||
|
return (&xmlDeregisterNodeDefaultValue);
|
||||||
|
else
|
||||||
|
return (&xmlGetGlobalState()->xmlDeregisterNodeDefaultValue);
|
||||||
|
}
|
||||||
|
@@ -52,6 +52,11 @@ extern "C" {
|
|||||||
#undef xmlRealloc
|
#undef xmlRealloc
|
||||||
#undef xmlSaveNoEmptyTags
|
#undef xmlSaveNoEmptyTags
|
||||||
#undef xmlSubstituteEntitiesDefaultValue
|
#undef xmlSubstituteEntitiesDefaultValue
|
||||||
|
#undef xmlRegisterNodeDefaultValue
|
||||||
|
#undef xmlDeregisterNodeDefaultValue
|
||||||
|
|
||||||
|
typedef void (*xmlRegisterNodeFunc)(xmlNodePtr node);
|
||||||
|
typedef void (*xmlDeregisterNodeFunc)(xmlNodePtr node);
|
||||||
|
|
||||||
typedef struct _xmlGlobalState xmlGlobalState;
|
typedef struct _xmlGlobalState xmlGlobalState;
|
||||||
typedef xmlGlobalState *xmlGlobalStatePtr;
|
typedef xmlGlobalState *xmlGlobalStatePtr;
|
||||||
@@ -89,6 +94,9 @@ struct _xmlGlobalState
|
|||||||
int xmlSaveNoEmptyTags;
|
int xmlSaveNoEmptyTags;
|
||||||
int xmlIndentTreeOutput;
|
int xmlIndentTreeOutput;
|
||||||
const char *xmlTreeIndentString;
|
const char *xmlTreeIndentString;
|
||||||
|
|
||||||
|
xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
|
||||||
|
xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -101,6 +109,9 @@ extern "C" {
|
|||||||
|
|
||||||
void xmlInitializeGlobalState(xmlGlobalStatePtr gs);
|
void xmlInitializeGlobalState(xmlGlobalStatePtr gs);
|
||||||
|
|
||||||
|
xmlRegisterNodeFunc xmlRegisterNodeDefault(xmlRegisterNodeFunc func);
|
||||||
|
xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In general the memory allocation entry points are not kept
|
* In general the memory allocation entry points are not kept
|
||||||
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
* thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED
|
||||||
@@ -329,6 +340,22 @@ extern int *__xmlSubstituteEntitiesDefaultValue(void);
|
|||||||
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
|
LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern xmlRegisterNodeFunc *__xmlRegisterNodeDefaultValue(void);
|
||||||
|
#ifdef LIBXML_THREAD_ENABLED
|
||||||
|
#define xmlRegisterNodeDefaultValue \
|
||||||
|
(*(__xmlRegisterNodeDefaultValue()))
|
||||||
|
#else
|
||||||
|
LIBXML_DLL_IMPORT extern xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern xmlDeregisterNodeFunc *__xmlDeregisterNodeDefaultValue(void);
|
||||||
|
#ifdef LIBXML_THREAD_ENABLED
|
||||||
|
#define xmlDeregisterNodeDefaultValue \
|
||||||
|
(*(__xmlDeregisterNodeDefaultValue()))
|
||||||
|
#else
|
||||||
|
LIBXML_DLL_IMPORT extern xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
83
tree.c
83
tree.c
@@ -338,6 +338,8 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
|
|||||||
doc->extSubset = cur;
|
doc->extSubset = cur;
|
||||||
cur->doc = doc;
|
cur->doc = doc;
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,6 +465,10 @@ xmlFreeDtd(xmlDtdPtr cur) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlDeregisterNodeDefaultValue)
|
||||||
|
xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
|
|
||||||
if (cur->children != NULL) {
|
if (cur->children != NULL) {
|
||||||
xmlNodePtr next, c = cur->children;
|
xmlNodePtr next, c = cur->children;
|
||||||
|
|
||||||
@@ -530,6 +536,9 @@ xmlNewDoc(const xmlChar *version) {
|
|||||||
cur->compression = -1; /* not initialized */
|
cur->compression = -1; /* not initialized */
|
||||||
cur->doc = cur;
|
cur->doc = cur;
|
||||||
cur->charset = XML_CHAR_ENCODING_UTF8;
|
cur->charset = XML_CHAR_ENCODING_UTF8;
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -550,6 +559,10 @@ xmlFreeDoc(xmlDocPtr cur) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlDeregisterNodeDefaultValue)
|
||||||
|
xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do this before freeing the children list to avoid ID lookups
|
* Do this before freeing the children list to avoid ID lookups
|
||||||
*/
|
*/
|
||||||
@@ -1127,6 +1140,9 @@ xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
|
|||||||
cur->prev = prev;
|
cur->prev = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,6 +1220,9 @@ xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
|||||||
cur->prev = prev;
|
cur->prev = prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1333,6 +1352,9 @@ xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) {
|
|||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1374,6 +1396,10 @@ xmlFreeProp(xmlAttrPtr cur) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlDeregisterNodeDefaultValue)
|
||||||
|
xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
|
|
||||||
/* Check for ID removal -> leading to invalid references ! */
|
/* Check for ID removal -> leading to invalid references ! */
|
||||||
if ((cur->parent != NULL) && (cur->parent->doc != NULL) &&
|
if ((cur->parent != NULL) && (cur->parent->doc != NULL) &&
|
||||||
((cur->parent->doc->intSubset != NULL) ||
|
((cur->parent->doc->intSubset != NULL) ||
|
||||||
@@ -1471,6 +1497,9 @@ xmlNewPI(const xmlChar *name, const xmlChar *content) {
|
|||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
cur->content = xmlStrdup(content);
|
cur->content = xmlStrdup(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1509,6 +1538,9 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
|
|||||||
|
|
||||||
cur->name = xmlStrdup(name);
|
cur->name = xmlStrdup(name);
|
||||||
cur->ns = ns;
|
cur->ns = ns;
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1579,6 +1611,7 @@ xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
|||||||
UPDATE_LAST_CHILD_AND_PARENT(cur)
|
UPDATE_LAST_CHILD_AND_PARENT(cur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1667,6 +1700,9 @@ xmlNewDocFragment(xmlDocPtr doc) {
|
|||||||
cur->type = XML_DOCUMENT_FRAG_NODE;
|
cur->type = XML_DOCUMENT_FRAG_NODE;
|
||||||
|
|
||||||
cur->doc = doc;
|
cur->doc = doc;
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1697,6 +1733,9 @@ xmlNewText(const xmlChar *content) {
|
|||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
cur->content = xmlStrdup(content);
|
cur->content = xmlStrdup(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1797,6 +1836,9 @@ xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) {
|
|||||||
cur->name = xmlStrndup(name, len);
|
cur->name = xmlStrndup(name, len);
|
||||||
} else
|
} else
|
||||||
cur->name = xmlStrdup(name);
|
cur->name = xmlStrdup(name);
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1848,6 +1890,9 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
|
|||||||
cur->children = (xmlNodePtr) ent;
|
cur->children = (xmlNodePtr) ent;
|
||||||
cur->last = (xmlNodePtr) ent;
|
cur->last = (xmlNodePtr) ent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1896,6 +1941,9 @@ xmlNewTextLen(const xmlChar *content, int len) {
|
|||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
cur->content = xmlStrndup(content, len);
|
cur->content = xmlStrndup(content, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1945,6 +1993,9 @@ xmlNewComment(const xmlChar *content) {
|
|||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
cur->content = xmlStrdup(content);
|
cur->content = xmlStrdup(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1977,6 +2028,9 @@ xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len) {
|
|||||||
if (content != NULL) {
|
if (content != NULL) {
|
||||||
cur->content = xmlStrndup(content, len);
|
cur->content = xmlStrndup(content, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlRegisterNodeDefaultValue)
|
||||||
|
xmlRegisterNodeDefaultValue(cur);
|
||||||
return(cur);
|
return(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2398,6 +2452,9 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
|||||||
/*
|
/*
|
||||||
* add the first element at the end of the children list.
|
* add the first element at the end of the children list.
|
||||||
*/
|
*/
|
||||||
|
if (cur->parent == parent)
|
||||||
|
return(cur);
|
||||||
|
|
||||||
if (parent->children == NULL) {
|
if (parent->children == NULL) {
|
||||||
parent->children = cur;
|
parent->children = cur;
|
||||||
} else {
|
} else {
|
||||||
@@ -2407,7 +2464,7 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
|||||||
if ((cur->type == XML_TEXT_NODE) &&
|
if ((cur->type == XML_TEXT_NODE) &&
|
||||||
(parent->last->type == XML_TEXT_NODE) &&
|
(parent->last->type == XML_TEXT_NODE) &&
|
||||||
(cur->name == parent->last->name)) {
|
(cur->name == parent->last->name)) {
|
||||||
xmlNodeAddContent(parent->last, cur->content);
|
xmlNodeAddContent(parent->last, cur->content);
|
||||||
/*
|
/*
|
||||||
* if it's the only child, nothing more to be done.
|
* if it's the only child, nothing more to be done.
|
||||||
*/
|
*/
|
||||||
@@ -2477,13 +2534,15 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
|||||||
*/
|
*/
|
||||||
if (cur->type == XML_TEXT_NODE) {
|
if (cur->type == XML_TEXT_NODE) {
|
||||||
if ((parent->type == XML_TEXT_NODE) &&
|
if ((parent->type == XML_TEXT_NODE) &&
|
||||||
(parent->content != NULL)) {
|
(parent->content != NULL) &&
|
||||||
|
(parent != cur)) {
|
||||||
xmlNodeAddContent(parent, cur->content);
|
xmlNodeAddContent(parent, cur->content);
|
||||||
xmlFreeNode(cur);
|
xmlFreeNode(cur);
|
||||||
return(parent);
|
return(parent);
|
||||||
}
|
}
|
||||||
if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE) &&
|
if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE) &&
|
||||||
(parent->last->name == cur->name)) {
|
(parent->last->name == cur->name) &&
|
||||||
|
(parent->last != cur)) {
|
||||||
xmlNodeAddContent(parent->last, cur->content);
|
xmlNodeAddContent(parent->last, cur->content);
|
||||||
xmlFreeNode(cur);
|
xmlFreeNode(cur);
|
||||||
return(parent->last);
|
return(parent->last);
|
||||||
@@ -2493,16 +2552,23 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
|||||||
/*
|
/*
|
||||||
* add the new element at the end of the children list.
|
* add the new element at the end of the children list.
|
||||||
*/
|
*/
|
||||||
|
prev = cur->parent;
|
||||||
cur->parent = parent;
|
cur->parent = parent;
|
||||||
if (cur->doc != parent->doc) {
|
if (cur->doc != parent->doc) {
|
||||||
xmlSetTreeDoc(cur, parent->doc);
|
xmlSetTreeDoc(cur, parent->doc);
|
||||||
}
|
}
|
||||||
|
/* this check prevents a loop on tree-traversions if a developer
|
||||||
|
* tries to add a node to its parent multiple times
|
||||||
|
*/
|
||||||
|
if (prev == parent)
|
||||||
|
return(cur);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Coalescing
|
* Coalescing
|
||||||
*/
|
*/
|
||||||
if ((parent->type == XML_TEXT_NODE) &&
|
if ((parent->type == XML_TEXT_NODE) &&
|
||||||
(parent->content != NULL)) {
|
(parent->content != NULL) &&
|
||||||
|
(parent != cur)) {
|
||||||
xmlNodeAddContent(parent, cur->content);
|
xmlNodeAddContent(parent, cur->content);
|
||||||
xmlFreeNode(cur);
|
xmlFreeNode(cur);
|
||||||
return(parent);
|
return(parent);
|
||||||
@@ -2588,6 +2654,10 @@ xmlFreeNodeList(xmlNodePtr cur) {
|
|||||||
next = cur->next;
|
next = cur->next;
|
||||||
/* unroll to speed up freeing the document */
|
/* unroll to speed up freeing the document */
|
||||||
if (cur->type != XML_DTD_NODE) {
|
if (cur->type != XML_DTD_NODE) {
|
||||||
|
|
||||||
|
if (xmlDeregisterNodeDefaultValue)
|
||||||
|
xmlDeregisterNodeDefaultValue(cur);
|
||||||
|
|
||||||
if ((cur->children != NULL) &&
|
if ((cur->children != NULL) &&
|
||||||
(cur->type != XML_ENTITY_REF_NODE))
|
(cur->type != XML_ENTITY_REF_NODE))
|
||||||
xmlFreeNodeList(cur->children);
|
xmlFreeNodeList(cur->children);
|
||||||
@@ -2655,6 +2725,7 @@ xmlFreeNode(xmlNodePtr cur) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use xmlFreeDtd for DTD nodes */
|
/* use xmlFreeDtd for DTD nodes */
|
||||||
if (cur->type == XML_DTD_NODE) {
|
if (cur->type == XML_DTD_NODE) {
|
||||||
xmlFreeDtd((xmlDtdPtr) cur);
|
xmlFreeDtd((xmlDtdPtr) cur);
|
||||||
@@ -2668,6 +2739,10 @@ xmlFreeNode(xmlNodePtr cur) {
|
|||||||
xmlFreeProp((xmlAttrPtr) cur);
|
xmlFreeProp((xmlAttrPtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xmlDeregisterNodeDefaultValue)
|
||||||
|
xmlDeregisterNodeDefaultValue(cur);
|
||||||
|
|
||||||
if ((cur->children != NULL) &&
|
if ((cur->children != NULL) &&
|
||||||
(cur->type != XML_ENTITY_REF_NODE))
|
(cur->type != XML_ENTITY_REF_NODE))
|
||||||
xmlFreeNodeList(cur->children);
|
xmlFreeNodeList(cur->children);
|
||||||
|
Reference in New Issue
Block a user