diff --git a/data/foreign-array.lisp b/data/foreign-array.lisp index d550a2c38c0de5057d95864facff48a6d99c4f57..3e78e95eebce66c22d9c49ca1520171eb9966c16 100644 --- a/data/foreign-array.lisp +++ b/data/foreign-array.lisp @@ -1,6 +1,6 @@ ;; A grid:foreign-array with added metadata for GSL. ;; Liam Healy 2008-04-06 21:23:41EDT -;; Time-stamp: <2010-07-13 10:24:43EDT foreign-array.lisp> +;; Time-stamp: <2010-07-13 12:06:45EDT foreign-array.lisp> ;; ;; Copyright 2008, 2009, 2010 Liam M. Healy ;; Distributed under the terms of the GNU General Public License @@ -75,7 +75,8 @@ ;; foreign-array. (defun make-foreign-array-from-mpointer - (mpointer &optional (element-type 'double-float) (category :vector)) + (mpointer + &optional (element-type 'double-float) (category :vector) finalize) "Make the foreign array when a GSL pointer to a gsl-vector-c or gsl-matrix-c is given." (let* ((cstruct @@ -95,6 +96,7 @@ ,(cffi:foreign-slot-value mpointer cstruct 'size1)) ,element-type))) :foreign-pointer - (cffi:foreign-slot-value mpointer cstruct 'data)))) + (cffi:foreign-slot-value mpointer cstruct 'data) + :finalizer finalize))) (setf (grid:metadata-slot fa 'mpointer) mpointer) fa)) diff --git a/init/funcallable.lisp b/init/funcallable.lisp index a4358d5a1d531bb47573cd4a96e3cefaf491cd8b..7a518d1ef88c23708975ffd7b70d4c5dc9291d26 100644 --- a/init/funcallable.lisp +++ b/init/funcallable.lisp @@ -1,6 +1,6 @@ ;; Generate a lambda that calls the user function; will be called by callback. ;; Liam Healy -;; Time-stamp: <2010-07-13 10:37:28EDT funcallable.lisp> +;; Time-stamp: <2010-07-13 12:06:01EDT funcallable.lisp> ;; ;; Copyright 2009, 2010 Liam M. Healy ;; Distributed under the terms of the GNU General Public License @@ -68,7 +68,8 @@ `(make-foreign-array-from-mpointer ,ptr ',(grid:cffi-cl (parse-callback-argspec argspec 'element-type)) - ,(length (parse-callback-argspec argspec 'dimensions)))) + ,(length (parse-callback-argspec argspec 'dimensions)) + t)) (:cvector ; a raw C vector `(grid:make-foreign-array-from-pointer ,ptr