
On Tue, Dec 19, 2006 at 07:26:26PM +0000, Daniel P. Berrange wrote:
On Tue, Dec 19, 2006 at 02:05:32PM -0500, Daniel Veillard wrote:
+ value = malloc(sizeof(virConfValue)); + value->str = strdup(filename); + free(value); + return (-1);
This makes me think about an idea I had to swicth all allocations in libvirt to reuse xmlMalloc/xmlFree/xmlStrdup . The reasons are the following: - libxml2 is a mandatory module - libxml2 memory debug allow to track easilly memory allocations and check we never leak, this can be really useful - libxml2 memory routines can also be overiden by the library client to use a different allocator which in some circumstances can be really useful
My prime motivation is debug but reuse of libxml2 facilities is not neglectible.
Sounds reasonble. I'm not familiar with libxml2 debug stuff though - does it give more info that we can get from valgrind ?
Frankly no, but there isn't the same cost penalty. Also one can track a given piece of memory, for example under gdb. Documentation at: http://xmlsoft.org/xmlmem.html 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/