Is there a GC'd malloc alternative?

Sean Kelly sean at f4.ca
Mon Feb 19 14:26:46 PST 2007


0ffh wrote:
> 
> [Now, is this the right newsgroup? I am confused...]
> 
> Hi, I'm new to D but got into it pretty quickly...
> it's heaven for a lazy old C coder! }:->>>
> 
> I just wonder if there is no library function that
> works like 'malloc' but in garbage collected memory?
> 
> Happy hacking, 0ffh
> 
> p.s.
> I am probably not looking for the 'new' operator,
> as 'new' seems to take only certain types as
> "argument", not the size of the requested memory
> chunk, as does 'malloc'.

In Tango, you'd do:

     import tango.core.Memory;

     void* rawbuf = gc.malloc( 512 );
     void* zerobuf = gc.calloc( 512 );


Sean



More information about the Digitalmars-d mailing list