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:49:17 UTC 2019


On Thursday, 28 February 2019 at 04:26:47 UTC, Sam Johnson wrote:
> Update: it seems that all I need to do is GC.addRoot(output); 
> and memory leak goes away. I think I have answered my own 
> question.

That shouldn't have any effect at all. GC.addRoot makes the GC 
consider that pointer to always be live. If it isn't already a 
GC'd pointer, the call does nothing, and if it is a GC pointer, 
it means it will never be collected!

Your test must be seeing something else...


More information about the Digitalmars-d-learn mailing list