
15 Sep
2001
15 Sep
'01
5:15 a.m.
Fri, 14 Sep 2001 23:40:42 -0700, Ashley Yakeley
I'm looking for a function that will convert a [Word8] byte-array to a CString (i.e. a C byte array) for the purposes of FFI.
You can use newArray which allocates the C byte array using malloc so it must be freed by free, and cast the resulting pointer from Ptr Word8 to CString using castPtr. When the array is temporary, it's better (and faster) to use withArray list_of_Word8 $ \word8Ptr -> let cstring = castPtr word8Ptr in ...
And it has to be the _same_ list of bytes that comes through on the native side.
I don't unserstand this. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK