On 7/20/06, Evan Martin <[EMAIL PROTECTED]> wrote:
The tricky part is that to pass in Haskell functions, I need to use
the FFI "wrapper" import, which means I need to later free them.  But
the only place I can free them is within the "free" callback, and I've
just discovered this isn't allowed!

free_fcn is normally a static function. It shouldn't need to free
itself. I'm thinking something like:

type Callback = StablePtr (Callback, DataStructure)-> IO ()
foreign import ccall "wrapper" mkCallback :: Callback -> IO (FunPtr Callback)
foreign export "free_fcn" free_fcn :: Callback

free_fcn sp = do
   (cb, ds) <- deRefStablePtr sp
   freeStablePtr sp
   freeHaskellFunPtr cb

--
Taral <[EMAIL PROTECTED]>
"You can't prove anything."
   -- Gödel's Incompetence Theorem
_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to