Re: [xml] xmlAddChild question



On Mon, Apr 16, 2012 at 08:52:06AM -0500, Bruce Sinclair wrote:
Daniel,

Thanks, but I think you omitted a special case.  My memory leak
was caused when I used xmlChildNode to add an empty text node.
The xmlChildNode function succeeded (non-null returned) but the text

  You mean xmlAddChild() right ? that's what we talked about and
there is no xmlChildNode() function ?!?

node was neither freed nor linked into the tree.  This lost 109 bytes
per occurrence and was inside a large document with many empty text
nodes being constructed multiple times (the document was freed before
constructing another).  Eventually, the leak overwhelmed the memory
manager.  I fixed the leak by testing for an empty text node and not
attempting to add it as a child.  I was just curious if this was a bug
or my lack of understanding of xmlChildNode.  You explanation helps,
but did not address the addition of an empty text node.

  That sounds like a bug, but I really don't see how that could happen.
Actually none of the code of xmlAddChild check for a null content of a
text none. Either it appends cur->content to existing content and free
cur unconditionally or it adds the children to the list.
  Are you sure it's the right function ?

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]