Convert C array pointer to a D slice without data copy

Marco Leise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 18 07:56:01 PDT 2015


Am Mon, 18 May 2015 09:51:48 +0000
schrieb "John Colvin" <john.loughran.colvin at gmail.com>:

> No need to worry about the GC here, it only scans the stack and 
> its own heap (unless you specifically add a new root).

And even if you add a root it wont free anything it did not
allocate itself! You could even append to your C array. It
will check how much capacity the slice still has on the GC
heap and after realizing the .ptr is not even in one of its
pools, allocate a GC copy of the C array right away.

-- 
Marco



More information about the Digitalmars-d-learn mailing list