Open jac3km4 opened 5 years ago
Brilliant usage of withPrimVectorSafe
, which should be able to do the unpinned/pinned conversion automatically.
The bytesFromByteString
can be improved because CBytes.fromCString
will always copy the bytes content and add a NUL terminator (which is part of CBytes
's invariant). We can save this copy by looking into ByteString
's constructor (then ForeignPtr
's constructor) directly.
I will definitely accept a patch adding these functions, you can add them in Std.Data.Vector.Base
, and re-export from Std.Data.Vector
if you want. Add another section in the export list is preferred.
I think they'd be pretty useful when using stdio with other libraries, I needed to define them in order to use proto-lens. Those seem to work for me: