On 7/20/06, Evan Martin [EMAIL PROTECTED] wrote:
But I also don't quite understand how the typing works out.
For example, can you use StablePtr directly with FFI functions, or do
they require you casting through Ptr?
Yes. You can use any Storable with FFI functions, as far as I know.
StablePtr
Suppose I have a C function like this:
void register_callback(
void (*callback_fcn)(void *data),
void *callback_data,
void (*free_fcn)(void *data));
I think this is pretty common in C libraries. The idea is that you
can register a callback along with a pointer to some data to pass to
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!
On 7/20/06, Evan Martin [EMAIL PROTECTED] wrote:
To elaborate, the code setting this up looks something like this:
callback_fcn - ... -- get a FunPtr using wrapper from the ffi
free_fcn - ... -- as above
-- the callback data is just stuff that needs freeing
callback_data - newStablePtr
On 7/21/06, Taral [EMAIL PROTECTED] wrote:
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