
13 Nov
2006
13 Nov
'06
1:45 a.m.
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:
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. Thanks, Donn Cave, donn@drizzle.com