How to destruct class instances allocated by a Region-allocator over a single GC block

Alexandru Jercaianu alex.jercaianu at gmail.com
Mon Apr 2 20:43:01 UTC 2018


On Monday, 2 April 2018 at 14:52:34 UTC, Per Nordlöw wrote:
> As a follow-up to
>
> https://forum.dlang.org/post/jfgpngdudtprzznrckwf@forum.dlang.org
>
> [...]

Hi,

I am not completely sure how to solve this, but maybe we can find 
some clues here [1].
It seems like we should use addRoot on the buffer returned by 
GC.instance.allocate to keep it alive.
Then, we can use addRange on each node after allocation and 
somehow use 'TypeInfo' to trigger destructors.
I'll dig into this more tomorrow and come back with a better 
answer.

Thanks,
Alex

[1] - https://dlang.org/phobos/core_memory.html


More information about the Digitalmars-d-learn mailing list