Re: [xml] Is this condition (xmlFreeNodeList) supposed to crash?
- From: Tomas Sieger <tomas sieger systinet com>
- To: Jose Commins <axora myrealbox com>
- Cc: xml gnome org
- Subject: Re: [xml] Is this condition (xmlFreeNodeList) supposed to crash?
- Date: Tue, 30 Nov 2004 15:54:07 +0100
Jose Commins wrote:
If I perform this:
output_root_element = xmlDocGetRootElement(output_doc);
xmlFreeNodeList(output_root_element);
xmlFreeDoc(output_doc);
I get a crash.
If I remove 'xmlFreeNodeList' it doesn't crash. Now, I don't
normally use 'xmlFreeNodeList' but I've seen many examples on this list
that do so, therefore I put in the line of code just to see what
happened. In my XML doc I have nodes attached to 'output_doc' that I've
created. Is the above code supposed to crash or is there something I am
not aware of?
Regards,
Jose.
Read the documentation. Well, xmlFreeNodeList() does not say a lot, but
when you look at xmlFreeNode, it says:
"This doesn't unlink the child from the list,
use xmlUnlinkNode() first."
So, your problem is that you try to free the nodes twice: once using
xmlFreeNodeList(), second via xmlFreeDoc().
Do not call xmlFreeNodeList() unless you also unlink the nodes from the
tree.
hope it helps
Tomas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]