A question regarding the GC

Sean Kelly sean at invisibleduck.org
Sun Jul 20 11:35:51 PDT 2008


bearophile wrote:
> torhu:
>> Are you aware of std.gc.capacity()?
> 
> The docs say:
>> uint capacity(void* p); Returns capacity (size of the memory block) that p points to the beginning of. If p does not point into the gc memory pool, or does not point to the beginning of an allocated memory block, 0 is returned.<
> 
> Is it safe to read/write all the bytes of such capacity (even if it's higher than the size of the requested memory block)?

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 :-)


Sean


More information about the Digitalmars-d-learn mailing list