new ForeignPtr without finalizers
Alastair Reid
alastair at reid-consulting-uk.ltd.uk
Mon Jun 9 05:01:50 EDT 2003
On Monday 09 June 2003 4:59 am, Ashley Yakeley wrote:
> OK, I just upgraded to GHC 6.0. How do I create a new ForeignPtr that
> doesn't have any finalizers?
>
> newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a)
> newSimpleForeignPtr ptr = ??
There is no direct way in the ffi. You could define a dummy function in C:
void dummy(HsPtr x) {}
and use:
newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a)
newSimpleForeignPtr ptr = newForeignPtr ptr dummy
foreign import ccall "&" dummy :: FinalizerPtr
It looks like you're using an idiom we didn't think of when designing the
library. Can you explain what you're trying to do and whether you think we
shoud provide direct support for newSimpleForeignPtr (which I'd be tempted to
call newForeignPtr_).
--
Alastair Reid
More information about the FFI
mailing list