Re: [xml] How can I use xmlMemFree() instead of free() ?

On Sat, Jul 26, 2008 at 10:31:32PM -0500, ChoiJason wrote:

Now I use xmlFree in my application.
And I found xmlFree is mapped to xmlMemFree() or free() in globals.c
Then I copied the from /usr/local/lib to /usr/lib.
And I tracked the operation of xmlFree in my program with GDB.
And I found xmlFree is mapped to free() in my case.
So, I added 
#define DEBUG_MEMORY_LOCATION 1 in /include/libxml/globals.h
Then I could see xmlFree is mapped to xmlMemFree() instead of free().
But I don't think this is not proper methodology to use xmlMemFree() instead of free().
Can I ask what is right way to use xmlMemFree()?
Please give me some recommendations.

  Read the documentation !
 When configured using --with-mem-debug flag (off by default), libxml2 uses
a set of memory allocation debugging...

 if you do memory debugging configure with --with-mem-debug ...
but if you do this your application will crash if you use xmlFree instead of
free() and vice-versa. That memory debugging is only applicable if you use
xmlFree at the right places as libxml2 keep its own data for all allocated
memory done by the library and that is incompatible with the standard C 

  If it's too complex for you, use valgrind !

  You should never call xmlMemFree directly.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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