mallocForeignPtr vs. C

Edward Z. Yang ezyang at MIT.EDU
Mon Jul 12 15:54:28 EDT 2010


Excerpts from Evan Laforge's message of Mon Jul 12 14:56:11 -0400 2010:
> But I'm not convinced that's actually enough because the C code is
> still running outside of a withForeignPtr.  I would have to do
> something really hairy like call back to C from the haskell callback,
> wrapping it in withForeignPtr.  Is there a better way to convince the
> GC that the pointer should remain alive until I explicitly release it
> from C?  The ideal I think would be a ref count that would keep the
> pointer alive while >0, that could be decremented from C.

The function you are looking for is withForeignPtr.  touchForeignPtr also
works.

Cheers,
Edward


More information about the Glasgow-haskell-users mailing list