[gdome]Gdome providing free()



Shouldn't gdome2 provide its own version of free() to free memory that
is allocated in libxml2 and gdome2 and passed to the calling code?
This free would basically be wrappers around libxml2's memory
allocation routines.

The libxml2 library provides the xmlMemSetup and xmlMemGet calls that
allow people to choose their own allocator.  By default, libxml2's
memory functions use just the system's malloc(), realloc and free(),
so there's no problem if the calling code uses free(), but if libxml2
is compiled with debugging support (if the code is compiled with
DEBUG_MEMORY_LOCATION or DEBUG_MEMORY defined, see libxml2/globals.c)
then libxml2's own allocator's are used and calling free() on these
pointers may cause a core dump.

BTW, this happens in gdome_di_saveDocToMemory*, which returns a buffer
to the caller that is allocated from libxml2.

I don't think this would be too much work to do to provide a
gdome_free().  Just call xmlMemGet(), get the free() function pointer,
and pass the pointer to it.

I'm guessing this function need to go into the vtable?

Best,
Blair

--
Blair Zajac <blair orcaware com>
Plots of your system's performance - http://www.orcaware.com/orca/



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