Managing malloced memory

anon anon at
Wed Oct 6 18:06:38 UTC 2021

I interface to a C library that gives me a malloced object. How 
can I manage that pointer so that it gets freed automatically.
What I've thought of so far:
* scope(exit): not an option because I want to return that memory
* struct wrapper: Doesn't work because if I pass it to another 
function, they also destroy it (sometimes). Also same problem as 
with scope(exit)
* struct wrapped in automem/ refcounted: The struct still leaves 
original scope and calls the destructor

More information about the Digitalmars-d-learn mailing list