Safely extend the size of a malloced memory block after realloc

Benjamin Thaut via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 18 05:18:15 PDT 2015


On Tuesday, 18 August 2015 at 10:27:14 UTC, Casper Færgemand 
wrote:
> On Monday, 17 August 2015 at 19:38:21 UTC, Steven Schveighoffer 
> wrote:
>>> // if the GC kicks in here we're f*****
>>> GC.addRange(mem, 512);
>>
>> Can't you GC.disable around this whole thing?
>
> GC.collect can still be called from another thread.

Good point, also GC.disable doesn't guarantee that the GC will 
never run. The documentation says that the GC may still run in 
out of memory or similar situations where it absolutely needs to 
run. So there isn't a safe way to do this after all.


More information about the Digitalmars-d mailing list