Fri, 28 Sep 2001 08:20:08 +0200, Sven Eric Panitz <[EMAIL PROTECTED]> pisze:

>     xs <- peekCString cxs
>     ys <- peekCString cys
>     erg <- return (xs++ys)

The last line can be written:
      let erg = xs++ys
and you can also directly write (xs++ys) instead of erg below.

>     newCString erg

All OK, except that you leak memory. This string is allocated using
malloc and should be freed using free when no longer needed (either
C free or Haskell free).

>    //calling Haskell function
>    test=cAppend("the world"," is my oyster"); 
> 
>    //printing its result
>    printf("%s\n", test);

And then: free(test);

BTW, there is less boilerplate (no startupHaskell etc.) when the main
program is in Haskell instead of C (of course sometimes this is not
what we want).

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZAST�PCZA
QRCZAK


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

Reply via email to