Re: [xml] How can I use xmlMemFree() instead of free() ?
- From: Daniel Veillard <veillard redhat com>
- To: ChoiJason <kbc_hyper hotmail com>
- Cc: xml gnome org
- Subject: Re: [xml] How can I use xmlMemFree() instead of free() ?
- Date: Fri, 1 Aug 2008 04:04:35 -0400
On Sat, Jul 26, 2008 at 10:31:32PM -0500, ChoiJason wrote:
Hi,,
Now I use xmlFree in my application.
And I found xmlFree is mapped to xmlMemFree() or free() in globals.c
[...]
Then I copied the libxml2.so.2.6.31 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 !
http://xmlsoft.org/xmlmem.html#Debugging
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
allocator.
If it's too complex for you, use valgrind !
You should never call xmlMemFree directly.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]