On Tue, Dec 19, 2006 at 04:35:00PM -0500, Daniel Veillard wrote: > 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 Actually there is one very useful usecase - multi threading. Valgrind is not multi-threaded at all - it more or less just runs each thread in turn for a few instructions before switching to next thread & so on. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|