<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div style="" class="">Thanks for your replies to my question, I was planning to go the trivial-garbage route and someone from CFFI-DEVEL kindly gave me this code to do GC automatically using my mat and del-mat functions<br style=""><br style="" class=""> (defstruct (cvmatrix (:constructor %make-cvmatrix))<br style="" class=""> (sap (mat) :type sb-sys:system-area-pointer :read-only t))<br style="" class=""><br style="" class=""> (defun make-cvmatrix ()<br style="" class=""> (let* ((matrix (%make-cvmatrix))<br style="" class=""> (sap (cvmatrix-sap matrix)))<br style="" class=""> (tg:finalize matrix (lambda (x) (del-mat sap)))<br style="" class=""> matrix))<br style="" class=""><br
style="" class="">When I run the make-cvmatrix function to create a matrix it outputs a struct instead of a pointer like i needed. I changed the last line of the make-cvmatrix function to be "sap" as below:<br style="" class=""><br style="" class=""> (tg:finalize matrix (lambda (x) (del-mat sap)))<br style="" class=""> sap))<br style="" class=""><br style="" class="">...and it appears to run poorly with only major variations in my ram levels which i suppose is just a result of lisps GC in process.<br style="" class="">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. <br style="" class=""><br style="" class="">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 :<br style="" class=""><br style="" class="">Mat* cv_create_Mat_typed(int rows, int cols, int
type) {<br style="" class=""> return new Mat(rows, cols, type);<br style="" class="">}<br style="" class=""><br style="" class="">eg:<br style="" class=""><br style="" class=""><br style="" class="">(defcfun ("cv_create_Mat_typed" mat-typed) (:pointer mat)<br style="" class=""> "MAT constructor with a row, column and type parameter."<br style="" class=""> (rows :int)<br style="" class=""> (cols :int)<br style="" class=""> (type :int))<br style="" class=""><br style="" class="">show me where the rows cols type params get placed in an edited finalizer/constructor above..I would definately appreciate greatly:), concrete examples using the code I posted.<br style="" class=""></div><div style="" class=""><br style="" class=""></div></div></body></html>