Thanks a lot for your feedback!
I have also intended to try finalization using a closure! But I wasn't that sure if it is an "idomatic" way to do that or there maybe an even more clever way for accomplishing it.
By further googling yesterday I have also found similar code fragments at
/http://code.google.com/p/lispbuilder/source/browse/trunk/lispbuilder-sdl/sdl...
I'm just wondering about "cffi:finalize" which I couldn't find in my own installation of cffi package!
Am I missing something?
Regards Nik
On 05/09/2011 12:16 AM, Luís Oliveira wrote:
On Sun, May 8, 2011 at 1:39 PM, Nitralimenitralime@googlemail.com wrote:
What would be a correct solution to avoid memory leaks in this situation? Using a finalizer seems to be a possible way to go. But I'm not sure how this can be done by just using the finalizer parameters "object" and "function" where "function" can't reliablely access "object" (cf. documentation of finalizer in "trivial-garbage" package)!!
Here's some pseudo-code to achieve what you're looking for:
(let ((ptr (grab-your-table-pointer))) (tg:finalize your-wrapper-object (lambda () (table-free ptr))))
HTH,