On Wednesday, 7 August 2013 at 15:21:56 UTC, Gary Willoughby wrote:
What's the D way of allocating memory? Do you guys just use malloc() and free()? Or are there functions in phobos that should be used? I just need a buffer of variable length allocating every now and then.

Allocating some garbage collected memory:

an array:
SomeType[] a = new SomeType[somePositiveInteger];
or
SomeType[][] m = new SomeType[][](somePosInt, someOtherPosInt);

a class
SomeClass b = new SomeClass(/*constructor args*/)



Sure, you can use malloc and free, but then of course you have to manage everything yourself

Reply via email to