2korden at gmail.com
Fri Jun 27 07:27:17 PDT 2008
On Fri, 27 Jun 2008 18:10:43 +0400, Jarrett Billingsley
<kb3ctd2 at yahoo.com> wrote:
> "Mael" <mael.primet at gmail.com> wrote in message
> news:g42p4r$2air$1 at digitalmars.com...
>> another newbie question :
>> I think it is possible to allocate unitialized data on the stack using
>> char mydata = void ;
>> is there a way to allocate unitialized data on the heap ?
> With Phobos, std.gc.malloc is supposed to return uninitialized data.
> a little template function to make it easy:
> import std.gc;
> T allocUninit(T)(size_t len)
> return (cast(T*)std.gc.malloc(len * T.sizeof))[0 .. len];
> auto arr = allocUninit!(char)(512);
> The equivalent in Tango is GC.malloc from tango.core.Memory.
This surely should be available at a language level.
More information about the Digitalmars-d-learn