Open mgkurtz opened 4 months ago
I've been thinking about this, and I'm not sure it's a good idea to expose internals like that; it's usually better to pull C values into Haskell and immediately free the C side instead. The main exception would be when you want to make a ByteString
from it, in which case you want https://downloads.haskell.org/ghc/9.2.5/docs/html/libraries/bytestring-0.11.3.1/Data-ByteString-Unsafe.html#v:unsafePackCStringFinalizer.
This is a draft for the concept discussed in #52. Actually, I did not even test it (beyond building). Quite likely, I have cheated when setting the type of
xFreePtr
toFinalizerPtr a = FunPtr (Ptr a → IO ())
instead ofFunPtr (Ptr a → IO Int)
. I do not know, what would be a clean solution here.As I am not very experienced with regards to Haskell building and testing, I would appreciate any help.