Newbie questions on memory allocation

Simen kjaeraas simen.kjaras at gmail.com
Sat Jul 24 09:54:18 PDT 2010


bearophile <bearophileHUGS at lycos.com> wrote:

> Deokjae Lee:
>
>> What's the meaning of the line A?
>
> It creates on the stack a 2-word structure, puts unsigned 3 in one word  
> and in the other word puts a pointer to a newly allocated area on the  
> GC-managed heap, that can contain 3 integers (plus one bookkeeping  
> byte), so this heap area is probably 4 words long or longer.

Check the code again. int[3] is stack-allocated. There is a temporary on
the heap, but it is thrown away after being used to initialize a.

-- 
Simen


More information about the Digitalmars-d-learn mailing list