Christian Lescher wrote:
> [...] I discovered that unpackCStringIO (module CStrings, package lang)
> produces a stack overflow when applied to strings > 65 KB, which seems a
> little strange to me. Is this a bug  - or at least a too stack-intensive
> implementation of unpackCStringIO?

A comment from CString.lhs:

   NOTE: unpackCStringIO must traverse the entire string before
   returning, since it is often used on dynamically allocated strings
   which need to be deallocated after unpacking.

This is done in a slightly stack-intensive way and could be hacked to stress
the heap instead. But this will probably never happen, as this part from
CString is effectively dead and deprecated, see

   http://www.haskell.org/ghc/docs/5.00/set/sec-cstring.html

for a better alternative.
 
> [..] BTW:  For passing back the string result, I use an addional C function
> "mallocAndStrCpy". Can I do without by replacing it with some Haskell
> code?

Again, have a look at the vastly improved libraries supporting the FFI.
Only downside: AFAIK, there is no 5.00 for Windoze yet...  :-}

Cheers,
   Sven

_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to