Skip to content

Conversation

mgkurtz
Copy link

@mgkurtz mgkurtz commented Apr 29, 2024

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 to FinalizerPtr a = FunPtr (Ptr a → IO ()) instead of FunPtr (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.

@geekosaur
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants