Could use help with foreign-free in Lisp's CFFI ?
Posted: Wed Oct 02, 2013 7:50 am
Some one suggested i call foreign-alloc inside my defun associated with my defcfun....the defun & defcfun are here:
[/code]
its a nice idea because i can write my code w/o usind the long foreign-alloc's in it but i was wondering how i use foreign-free then
I tried
and just
I thought of a block return-from but that seems like the same thing as above if you are a cffi user....how would you accomplish this:
[/code]
Code: Select all
;; CvMatND* cvInitMatNDHeader(CvMatND* mat,
int dims, const int* sizes, int type, void* data=NULL)
(cffi:defcfun ("cvInitMatNDHeader" %init-mat-nd-header) cv-mat-nd
(mat cv-mat-nd)
(dims :int)
(sizes :pointer)
(type :int)
(data :pointer))
(defun init-mat-nd-header (mat dims sizes type &optional (data (cffi:null-pointer)))
"Initializes a pre-allocated multi-dimensional array header."
(%init-mat-nd-header mat dims (cffi:foreign-alloc :int
:initial-contents sizes) type
(cffi:foreign-alloc :int :initial-contents data)))
I tried
Code: Select all
(defun init-mat-nd-header (mat dims sizes type &optional
(data (cffi:null-pointer)))
"Initializes a pre-allocated multi-dimensional array header."
(%init-mat-nd-header mat dims (cffi:foreign-alloc :int
:initial-contents sizes) type
(cffi:foreign-alloc :int :initial-contents data))
(return-from init-mat-nd-header data))
Code: Select all
(defun init-mat-nd-header (mat dims sizes type &optional
(data (cffi:null-pointer)))
"Initializes a pre-allocated multi-dimensional array header."
(%init-mat-nd-header mat dims (cffi:foreign-alloc :int
:initial-contents sizes) type
(cffi:foreign-alloc :int :initial-contents data))
data)