When writing bindings for a C library which performs memory allocations, how can we perform automatic memory management in the style of Julia with the external free functions? We want something similar to the defer keyword, like the following:
my_ptr = @ccall mylib.myAlloc(alloc_bytes)::Ptr{UInt8}
defer @ccall mylib.myFree(my_ptr)
Ideally we would like to plug into the garbage collector to make this kind of C call memory safe.