[cffi-devel] Calling function expecting char**
JoeSB COE9
joesb.coe9 at gmail.com
Tue Dec 27 17:59:46 UTC 2005
Hi,
How do I call a function that expect char**?
I test it with
/** C Code */
#include <stdio.h>
void expect_charpp(char** buffs){
printf("I got %s and %s", buffs[0], buffs[1]);
}
;; Lisp side
(cffi:with-foreign-object (argv :pointer 2)
(setf (cffi:mem-ref argv :pointer 0)
(cffi:foreign-string-alloc "Hello"))
(setf (cffi:mem-ref argv :pointer 1)
(cffi:foreign-string-alloc "Hello"))
(cffi:foreign-funcall "expect_charpp" :pointer argv))
And I got a memory fault error in SBCL.
If i comment out the code in C to make it not accessing the data, it
won't err. So it looks like the error is in how I allocate the memory.
Please advice.
Pisin Bootvong,
More information about the cffi-devel
mailing list