[Haskell-cafe] ByteString FFI

Donn Cave donn at drizzle.com
Mon Nov 13 01:45:27 EST 2006

On Mon, 13 Nov 2006, Donald Bruce Stewart wrote:

> And for custom data (not just C strings), if the withCString* functions
> don't quite fit, you can always pack the foreign Ptr into a ByteString
> by stepping inside the ByteString constructor:
>     http://www.haskell.org/haskellwiki/Wc#Going_via_C

That's actually what I tried first, but in this particular situation
(ghc-6.4.1 / fps-0.7), PS apparently isn't exported?

The CStringLen approach works, except that the allocated data doesn't
get garbage-collected.  Just for the sake of experiment I tried a regular
CString with packMallocCString, and that didn't leak nearly as much memory -
but still some, in a simple loop where "pack" doesn't leak anything.

	Donn Cave, donn at drizzle.com

More information about the Haskell-Cafe mailing list