Add array conversion to and from foreignptr
Closed this issue · 2 comments
harendra-kumar commented
Introduce something like toForeignPtr
and fromForeignPtr
so that we can implement the toArray
and fromArray
in streamly-bytestring.
adithyaov commented
toForeignPtr
does not make sense when bounds aren't involved. We pass in the
whole MutableByteArray#
to the ForeignPtr
which has the information of
arrayCapacity
but not arrayLength
.
(ForeignPtr, Int)
will have all the information of Array
without loss.
We can however introduce asForeignPtr
passing the length as well.
adithyaov commented
We have introduced unsafeAsForeignPtr