www.digitalmars.com         C & C++   DMDScript  

D - Is there a GC'd malloc alternative?

reply 0ffh <spam frankhirsch.net> writes:
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'.
Feb 19 2007
parent Johan Granberg <lijat.meREM OVE.gmail.com> writes:
0ffh wrote:

 
 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'.

are you sure about the new thing. I think that this code would work. new void[SIZE]; where SIZE is an integer representing how large chunk of memory you want to reserve. ps. this newsgroup is all but abandoned use the digitalmars.D instead.
Feb 19 2007