[Gc] Determine the requested size of a memory block

Henning Makholm makholm at octoshape.com
Fri Apr 23 02:25:31 PDT 2010

Hans Boehm writes:

> If someone has the time to invest here, it might be worth thinking about making
> the size optionally accurate to GC_GRANULE_BYTES and making
> GC_GRANULE_BYTES = 1 do something reasonable, so that you could optionally
> configure the collector to have this work.  But I think there are many bug-introduction
> possibilities there, particularly when it comes to GC_realloc.  (I'm not sure whether
> we need to worry about alignment issues, since objects should generally have a
> size that is a multiple of their alignment requirements.  But I may be overlooking some
> more fundamental issues.)

I don't know if it counts as "fundamental", but I think this could break alignment for
idioms such as
   GC_MALLOC(sizeof(struct header) + nbytes)
   GC_MALLOC(offsetof(struct mystruct, data[count])) // struct hack

Henning Makholm

More information about the Gc mailing list