Return a class instance as a pointer

Jacob Carlborg doob at me.com
Sat Mar 31 08:52:05 PDT 2012


On 2012-03-31 17:44, Andrej Mitrovic wrote:
> On 3/31/12, "Timo Westkämper\"<timo.westkamper at gmail.com>"@puremagic.com
>> Also in such a way that it is not claimed by GC.
>
> Probably save the reference somewhere. I think by just returning a
> void* to a C function the GC will think all references to the objects
> are gone and will eventually try to collect it.
>
> Perhaps you could keep a hash of objects:
> __gshared[Object] _store;

I think the correct way is to use core.memory.GC.addRoot.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list