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

Hello Bjoern,

Thank you for your help. Someone showed me that xmlNewDocFragment() is using xmlMalloc() : 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:

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.


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
>The libxml2 doc
>( 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
Am Badedeich 7 Â Telefon: +49(0)160/4415681 Â
25899 DagebÃll  PGP Pub. KeyID: 0xA4357E78


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