On 2/4/07, Thomas Christian Chust <[EMAIL PROTECTED]> wrote:
the address of the C function wrapping the define-external'ed Scheme procedure is unproblematic, because it will never change. The pointer to the C string data may become invalid, though, once the program returns from the library call. In order to make this safe, you would have to duplicate the string in the C heap (for example using strdup) or you would have to create a non-garbage-collected copy of the Scheme string (for example using object-copy) to pass that to the library routine. In either case you would have to release the string data later on when it is no longer needed.
Exactly. Another option would be to create a GC root (CHICKEN_new_gc_root) and keep it on the C-side (you have to pass the argument string as a scheme-object, then create the GC-root from it). Later, you can access the gc root (CHICKEN_gc_root_ref) and use the string. The gc root will be updated on every garbage collection. You just have to make sure you free it eventually (or just reuse it). cheers, felix _______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users