Force struct allocation on the heap?

Benji Smith dlanguage at benjismith.net
Sun Oct 19 08:09:22 PDT 2008


Jarrett Billingsley wrote:
> On Sun, Oct 19, 2008 at 12:25 AM, Benji Smith <dlanguage at benjismith.net> wrote:
>> Looking at the official docs, I can't find the D1 syntax for forcing a
>> struct to be allocated on the heap (so that it can safely be returned from a
>> function). I'm pretty sure it's possible (without wrapping the struct in a
>> class or an array), but I can't for the life of me remember how it's done.
> 
> ..you can always safely return a struct from a function, unless of
> course it has members that point onto the stack.

Oops. I meant to say that I need to return a struct *POINTER* from a 
function. In which case, I think I need to force heap allocation.

Thanks!

--benji


More information about the Digitalmars-d-learn mailing list