how to pass a malloc'd C string over to be managed by the GC

Adam D. Ruppe destructionator at gmail.com
Thu Feb 28 04:47:25 UTC 2019


On Thursday, 28 February 2019 at 03:35:45 UTC, Sam Johnson wrote:
> Ignore the `.clone()` call -- that wasn't supposed to be here 
> -- I thought maybe string.clone() might exist but it turns out 
> it does not.

It is called `.dup` ( for a mutable copy) or `.idup` (for an 
immutable copy).

Though note that while it would copy it into a GC array, it would 
leave the original - you'd still want to free() that.


More information about the Digitalmars-d-learn mailing list