What is the Correct way to Malloc in @nogc section?

Benjamin Thaut via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 16 02:30:43 PST 2015


Hi,

you can also take a look at my implementation:

https://github.com/Ingrater/druntime/blob/master/src/core/allocator.d

Look at AllocatorNew and AllocatorDelete

Especially important is, that you correctly handle the 
constructor throwing an exception. You have to catch that 
exception in your new function, release the memory and rethrow.

Kind Regards
Benjamin Thaut


More information about the Digitalmars-d-learn mailing list