Code: Select all
(defstruct (cvmatrix (:constructor %make-cvmatrix))
(sap (mat) :type sb-sys:system-area-pointer :read-only t))
(defun make-cvmatrix ()
(let* ((matrix (%make-cvmatrix))
(sap (cvmatrix-sap matrix)))
(tg:finalize matrix (lambda (x) (del-mat sap)))
matrix))
Code: Select all
(tg:finalize matrix (lambda (x) (del-mat sap)))
sap))
Since I'm new to GC w/ trivial-garbage, I was hoping someone can verify first that the change to sap was an ok move.
I was hoping someone could edit my code so I have a good example of Lisp GC with TG to work from and if I write a defcfun for this C wrapper :
Code: Select all
Mat* cv_create_Mat_typed(int rows, int cols, int type) {
return new Mat(rows, cols, type);
}
eg:
(defcfun ("cv_create_Mat_typed" mat-typed) (:pointer mat)
"MAT constructor with a row, column and type parameter."
(rows :int)
(cols :int)
(type :int))