Just for clarification: Is it OK to call freeHaskellFunPtr in the
Haskell function pointed to itself, i.e. a kind of "self destruction"?
Example:

    foreign import ccall "wrapper" makeCB :: IO () -> IO (FunPtr (IO ()))

    ...
    funPtr <- mfix (\self -> makeCB (do freeHaskellFunPtr self; ...))
    <register funPtr somewhere in C land>
    ...

The FFI spec doesn't say anything about this, but it would be very
handy if this was allowed, e.g. for one-shot callbacks. After a short
look into GHC's and Hugs' RTS I think it is OK for both systems: The
thunk/adjustor has always a jump at its end, so free-ing the machine
code at the jump destination does no harm.

Cheers,
    S.

_______________________________________________
FFI mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/ffi

Reply via email to