[plt-scheme] Questions about modules, compilation, namespaces, planet and ffi

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Apr 28 23:30:29 EDT 2005

On Apr 29, Bruno Deferrari wrote:
>   This is what I made for the list, is it right?? (at least, it
>   seems to work)
> ;====================================
> ; Make a list, and free the array
> (define-fun-syntax _list/free
>   (syntax-id-rules ()
>     [(_ t c) (type: _pointer
>               pre: (malloc c t)
>               post: (x => (begin0
>                             (cblock->list x t c)
>                             (free x))))]))

I'm confused now -- you said that the foreign function is the one that
allocates the vector, but in this code you do it, and you use the
default malloc, so the GC will take care of it for you.

>   Now, what about strings?? they also should be freed right??
>   Would this work?? (As the previous one, it seems to work)
> ; Make a string/utf-8, and free the char* pointer
> (define-fun-syntax _string/utf-8/free
>   (syntax-id-rules ()
>     [_ (type: _bytes
>         post: (x => (begin0
>                       (bytes->string/utf-8 x)
> 		      (free x))))]))

In this case it seems fine, since it looks like foreign code is what
mallocs the string.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.