mallocForeignPtr vs. C

Edward Z. Yang ezyang at MIT.EDU
Tue Jul 13 16:17:40 EDT 2010


Excerpts from Axel Simon's message of Tue Jul 13 16:03:01 -0400 2010:
> If your C code has a way to properly unref a pointer then you could  
> wrap your ForeignPtr in a StablePtr and pass that to C land. Once C  
> has freed the StablePtr the ForeignPtr can become dead when Haskell  
> has dropped all references and it will be garbage collected.

Does ForeignPtr have a guaranteed representation from C land?   I feel
like you want to create a stable pointer and then unsafely cast the
foreign pointer into a real pointer, which would effectively fizzle
the original foreign pointer's finalizer.

Cheers,
Edward


More information about the Glasgow-haskell-users mailing list