<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><span>If you get some free time I would love to see a concrete example, but I do appreciate you time so far and don't want to put you out in any way.. I'm building a big library and the better I can make each individual component the better<br></span></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Sunday, April 13, 2014 8:26 AM, Willem Rein Oudshoorn <woudshoo@xs4all.nl> wrote:<br> </font> </div> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px;
padding-left: 5px;"> <div class="y_msg_container">Joeish W <<a ymailto="mailto:joeish80829@yahoo.com" href="mailto:joeish80829@yahoo.com">joeish80829@yahoo.com</a>> writes:<br><br>> I already figured out a great finalizer, I could just use help on one thing.<br>> The below finalizer is for the %mat defcfun below that.<br>> How do I update the finalizer below to be for the mat-data defcfun at the <br>> bottom of the page. So where do I put the rows cols params, there seems <br>> to be no place for them in the defstruct wwhere %mat is called. Any<br>> help is appreciated <br><br>Hm, I feel this is not the right way to approach this. <br>However, there is a bug in your finalize logic.<br><br>1. If you call make-cvmatrix with enable-finalizer true you attach a<br> finalize on the new instance of cvmatrix. <br>2. However you return the SAP. <br>3. As a consequence the cvmatrix instance can be immediately
garbage<br> collected, even if the returned SAP still has references to it.<br><br> <br><br>> (defstruct (cvmatrix (:constructor %make-cvmatrix)) <br>> (sap (%mat) :type sb-sys:system-area-pointer :read-only t)) <br>> <br>> (defun make-cvmatrix (&optional enable-finalizer) <br>> (let* ((matrix (%make-cvmatrix)) <br>> (sap (cvmatrix-sap matrix))) <br>> (when enable-finalizer <br>> (tg:finalize matrix (lambda () (del-mat sap)))) <br>> sap)) <br><br>I do not think that this is what you want.<br><br>Two remarks for future improvement:<br><br>1. You use sb-sys:system-area-pointer as type, and this will tie you to<br> SBCL. There is no reason for that.<br><br>2. You should read up on `translate-to-foreign' and<br> `translate-from-foreign' in the cffi
documentation. It will really<br> help to make the code simpler, cleaner and more robust.<br><br>If I have more time I might give some more detailed suggestions. But I<br>hope this helps a bit.<br><br>Wim Oudshoorn.<br><br><br>_______________________________________________<br>Cffi-devel mailing list<br><a ymailto="mailto:Cffi-devel@common-lisp.net" href="mailto:Cffi-devel@common-lisp.net">Cffi-devel@common-lisp.net</a><br><a href="http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel</a><br><br><br></div> </blockquote> </div> </div> </div> </div></body></html>