Return a class instance as a pointer

Timo Westkämper" <timo.westkamper at gmail.com> Timo Westkämper" <timo.westkamper at gmail.com>
Sat Mar 31 10:06:07 PDT 2012


On Saturday, 31 March 2012 at 15:52:07 UTC, Jacob Carlborg wrote:
> 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.

Thanks, I will try that.




More information about the Digitalmars-d mailing list