GLIB+win32 memory problem



I've written a little C++ wrapper for the GList object in glib (my class
implements the GList struct) and by the nature of my implementation (and
that of a linked list node) I've had to write my own "new" and "delete"
operators which basically wrap g_list_alloc() and g_list_free()
respectively.  this all works great as long as my subclass has no member
variables (say, for instance, a node-level mutex)--the requested
allocation size passed to "new" now is larger than sizeof(GList).  i've
tried to rectify this by calling g_list_alloc and then g_realloc( which
maps straight to system realloc ) which i now know is a big mistake
because g_list_alloc uses g_mem_chunk_* stuff (via a GAllocator* type).
i've tried taking a look at the g_mem_chunk_alloc (which is ultimately
called by g_list_alloc) to see if there is any way i can _safely_ and
_reliably_ let it know that i want a memory chunk no smaller than a
certain size.  do i even need to worry about this? (e.g. does
g_mem_chunk_alloc allocate more memory than say 32 bytes per chunk?
regardless, how do i change this number within the g_list_alloc
context?).

again, i should say that i came accross this error using glib 1.2.1 on
win32.

(p.s.  using g_realloc=realloc on the memory returned from g_list_alloc
generates an "invalid local heap ponter" maybe i should just try to
sidestep this instead?  if so how?  i've tried with no success)

Jacob Christen



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