hostinfo egg also contains an example array0->string-vector which takes a NULL-terminated array of char* and returns a vector of scheme strings. It also points you to how to construct a list instead. Drawback is you have to be careful that you don't allocate too much data or you'll overflow the nursery.
On 7/6/07, felix winkelmann <[EMAIL PROTECTED]> wrote:
On 7/6/07, foobar <[EMAIL PROTECTED]> wrote: > > Great thanks. Just to be sure i've done it correctly. > Here is an example on how i would return a list of one string element. > > (define return-a-list-with-string-elt > (foreign-primitive scheme-object () > "char str[] = \"hallo\";" > "C_word *sstr = C_alloc(C_SIZEOF_STRING(strlen(str)));" > "C_return(C_h_list(1,C_string2(&sstr,str)));"))
I'd perhaps do it this way: (foreign-primitive scheme-object () "char *str[] = \"hallo\";" "C_word *buf = C_alloc(C_SIZEOF_STRING(strlen(str)) + C_SIZEOF_PAIR);" "C_word str = C_string2(&buf, str);" "C_return(C_a_i_list(&buf, 1, str));")
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users