I have a C function that returns a pointer to an array
of strings.
char * * array_of_strings = foo(...);
The array is not zero terminated so I can't say
(ffi:def-call-out foo
(:return-type (ffi:c-array-ptr ffi:c-string))
...
And the array may vary in size depending on what
arguments foo is called with so the following
won't work either.
(:return-type (ffi:c-ptr (ffi:c-array-max ffi:c-string 20)))
20 is a number I pulled out of a hat. If 20 is smaller than the
array returned everything is okay. If the returned array is
smaller a segment fault is signaled.
The 20 can't be passed as a variable because the
ffi:parse-c-type function will reject the variable name
because it is not itself an integer.
The allocation of the array is handled by the C and not
of concern to the CLisp side, i.e. it is not responsible
for deallocation.
If I use the following definition
(:return-type ffi:c-pointer)
is there a way to then cast this to the proper value on the Lisp
of the FFI perimeter to pull the strings across on the fly?
I couldn't figure this out from the documentation or the examples.
(let ((array-of-string (foo ...)))
(ffi:cast array-of-string .... ?
Thanks for any help in advance.
John