Safely extend the size of a malloced memory block after realloc

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Aug 17 13:07:08 PDT 2015


On 8/17/15 3:57 PM, welkam wrote:
> // if the GC kicks in here we're f*****
>
> Why?
>
> static nothrow @nogc void removeRange(in void* p);
> Removes the memory range starting at p from an internal list of ranges
> to be scanned during a collection. <...>

Because presumably the reason why you have added the range is because 
it's not GC memory (as in this case). This means that if a GC run kicks 
in right then, that range of data will not be scanned, and the GC memory 
it may have been pointing at could potentially be freed.

-Steve


More information about the Digitalmars-d mailing list