Toby Butzon wrote:
[...]
I'm stumped. How do I get the string to turn into a Scheme string
without truncating it at the first embedded null?
[...]
Hello,
as far as I know, there is no way to tell the FFI to do this properly,
so you will have to do it by hand. Try something like this:
(define (c-memcpy from)
((foreign-primitive scheme-object ((scheme-pointer from) (int size))
"C_word *store = C_alloc(C_SIZEOF_STRING(size));\n"
"C_word to = C_string(&store, size, from);\n"
"C_values(2+1, C_SCHEME_UNDEFINED, C_k, to);")
from (string-length from)))
(define from (string #\1 #\nul #\2 #\nul #\3))
(display "from: ") (write (string->list from)) (newline)
(display "to: ") (write (string->list (c-memcpy from))) (newline)
cu,
Thomas Chust
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users