A question regarding the GC

Sean Kelly sean at invisibleduck.org
Sun Jul 20 13:01:47 PDT 2008


bearophile wrote:
> Sean Kelly:
>> Since the GC provides a method to obtain this information I believe that 
>> implicit permission has been given to use the capacity indicated.  After 
>> all, the GC wouldn't tell you about capacity it didn't want you to use :-)
> 
> I see.
> (So far I have meant the capacity value as the higher value the GC can realloc the memory block until it needs to copy the block to a new position. I have meant it as little useful value. Now I'll find better ways to use it, the first usage will probably be in the implementation of a templeted unrolled linked list :-) ).
> 
> Related note: the std.c.malloc() too must store the size of the allocated block somewhere, but I presume such value can't be found in simple ways...

You'd have to know how the allocator was implemented, or modify it (in 
the case of an open source allocator like nedmalloc) to add the routine. 
  This is one call that I wish had been in C from the start.  Oh well.


Sean


More information about the Digitalmars-d-learn mailing list