[Ecls-list] FFI and null C strings
Juan Jose Garcia Ripoll
lisp at arrakis.es
Wed Nov 24 07:27:46 UTC 2004
Goffioul Michael wrote:
>I found an annoying problem while fixing FFI issues. This is related
>to null C strings. One example is for example:
>(ffi:def-function ("getenv" c-getenv)
> ((name :cstring))
> :returning cstring)
>If the variable doesn't exist, "getenv" returns NULL. However, the
>generated C code convert the returned value to a LISP string using
>make_string_copy, which doesn't support NULL as input argument.
>Would it be OK to change make_string_copy such that it returns NIL
>when the input is NULL?
Does this issue pop very often? I do not remember many functions which
return a null pointer as a string. However, if this is so often that it
might be worth using, then I would vote for a new function
ecl_cstring_to_string_or_nil() The name is more clear and it does not
pervert an existing function which eventually should be replaced by a
ecl_string_to_string() that fails for NULL pointers.
More information about the ecl-devel