Re: [xml] How to free memory allocated with xmlNewDocFragment() ?



Hello Bjoern,

Thank you for your help. Someone showed me that xmlNewDocFragment() is using xmlMalloc() : http://git.gnome.org/browse/libxml2/tree/tree.c#n2396 therefore I assume the xmlFree() is ok.

Actually xmlFree() is called within gdome_xmlFreeNode() which ensures that all other parts of the structure are released before calling xmlFree(). see here: http://gdome2.sourcearchive.com/documentation/0.8.1plus-pdebian-2/gdome-xml-xmlmemory_8c-source.html

As for your last question, to be honnest I am not able to answer today, because I am just begining investigating this. I am expecting a cygwin-specific problem because the tests should run fine on appropriate platforms. But to find the answer, I guess I have to go through these memory problems.

Any hint is always welcome.

AG.

2011/2/9 Bjoern Hoehrmann <derhoermi gmx net>
* Alexandre Gouraud wrote:
>I am working on gdome2 in cygwin. The test suite fail. I am stuck in the
>debug somewhere with an invalid xmlFree() on a pointer allocated with
>xmlNewDocFragment().
>
>The libxml2 doc
>(http://xmlsoft.org/html/libxml-tree.html#xmlNewDocFragment) does
>not says what should be used to de-allocate memory allocated by
>xmlNewDocFragment(). Is xmlFree() the appropriate function to use in that
>case ?

A DocumentFragment is a Node so xmlFreeNode would seem the right method.
As I recall, xmlFree() ~ free(), so it would not care about memory the
Node holds, if any. The result however would seem to be a leak, not an
invalid deallocation, unless libxml2 does not use xmlFree()-able memory
for the Node. Has the DocumentFragment been added to some other node?
--
BjÃrn HÃhrmann  mailto:bjoern hoehrmann de  http://bjoern.hoehrmann.de
Am Badedeich 7 Â Telefon: +49(0)160/4415681 Â http://www.bjoernsworld.de
25899 DagebÃll  PGP Pub. KeyID: 0xA4357E78  http://www.websitedev.de/



--
Alexandre


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