From: Aurelio B. <a.b...@co...> - 2003-04-11 18:44:14
|
Recently I switched from gcc 2.95.3 to gcc 3.2.2. After recompiling CLISP, I discovered that, in some circumstances, FFI:CAST causes a segmentation fault. Test case: define the following foreign function: (def-call-out make-foreign-string (:name "make_foreign_string") (:arguments (s c-string :in)) (:return-type c-pointer :malloc-free)) void * make_foreign_string (const char *s) { int len = strlen(s); char *r = malloc (len); memcpy (r, s, len); return r; } try to convert its result to a '(c-ptr (c-array character ...)): [2]> (use-package :ffi) T [3]> (setf *x* (make-foreign-string "abcd")) #<FOREIGN-ADDRESS #x081B6680> [4]> (with-c-var (p 'c-pointer *x*) (cast p '(c-ptr (c-array uint8 4)))) #(97 98 99 100) OK, with bytes it works. [5]>(with-c-var (p 'c-pointer *x*) (cast p '(c-ptr (c-array character 4)))) Segmentation fault Any idea? |