From: Mathieu Bouchard Date: 2000-11-09T15:20:37+09:00 Subject: [ruby-talk:6192] Re: xmalloc(), xfree() > I'm currently trying to make changes to xmalloc/xrealloc/xfree. The [...] No-one replied. I'm trying again with another question: what do you think is best: * leave malloc/free as-is, make ruby use xmalloc/xfree; * make ruby use our own malloc/free; * leave things as they are now (disallows proper accounting of malloc'ed memory, allocation optimization, etc) * magical solution - the issue - I want to add one feature to the allocator: size_t xmsize (void *ptr); "returns the number of bytes allocated by the malloc operation that returned ptr. might be larger than the size originally asked for." My current implementation works by making all allocations bigger than requested, transparently, by sizeof(size_t). I store the size in *ptr, and return ptr+1 instead of ptr; I also do the inverse translations. But this implies that you can't xfree(malloc(...)) nor free(xmalloc(...)). matju