[xml] Memory leak / cleanup missing after node creation.
- From: Jose Commins <axora myrealbox com>
- To: xml gnome org
- Subject: [xml] Memory leak / cleanup missing after node creation.
- Date: Thu, 20 May 2004 20:49:25 +0100
(libxml2 - 2.6.10)
Hi, I am observing a leak when performing this walk/replace through
nodes:
static void process_XML_elements(xmlNode *a_node)
{
xmlNode *newNode = NULL;
xmlNode *cur_node = NULL;
for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
switch(cur_node->type)
{
case XML_ELEMENT_NODE:
if(!strcmp("aTest", cur_node->name))
{
newNode = xmlNewText(theTagReplacements[1]);
xmlReplaceNode(cur_node, newNode);
}
break;
default:
break;
}
process_XML_elements(cur_node->children);
}
}
'xmlFreeDoc' clears up the doc allocation but not the nodes assigned
above to replace the previous nodes. A kludge would be to maintain a
list of allocated nodes then freeing them individually, but it would be
nice if 'xmlFreeDoc' or similar freed all the nodes assigned to the doc
itself.
Regards,
Jose.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]