A way to allocate and initialize unmanaged memory with ffi.new-like syntax
Created originally on Bitbucket by waedt (Tyler Wade)
I would like to see cffi provide a way to allocate/initialize memory in a way similar to ffi.new
, but without the memory being freed automatically by cffi. My use case is returning a string from a callback. Using ffi.new
won't work because cffi will free the string automatically and while I can use malloc and copy the string manually, being able to simply write return ffi.unmanaged_new('char*', some_str)
would be much easier and more readable. (I'm not suggesting the name unmanaged_new
.)