|
From: | Zbigniew |
Subject: | Re: [Chicken-users] Setting up hooks in garbage collection |
Date: | Tue, 2 Jan 2007 17:24:22 -0600 |
I would think that your make-gsi-XXX could use set-finalizer! like so: (set-finalizer! obj (lambda (x) (gsi-xxx-free x))) It assumes you're willing to wait for a major GC and that you are sure this pointer is not being used anywhere else, although you would have the latter issue with an explicit free. If you're going to use finalizers very heavily, I would suggest you call csi with -:d to activate debugging just so you can see how the finalization is happening. On 1/2/07, Paulo Jabardo <address@hidden> wrote:
I'm beginning to develop a chicken interface to the GNU scientific library (gsl). Several numerical procedures involve an operation such as: gsl_XXX *ptr = gsl_XXX_alloc(...) ... gsl_XXX_free(ptr) I would like to define a chicken variable that manages the pointer. But I don't want to explicitely call the XXX_free function. Something like: (define resource (make-gsl-XXX ...)) When the garbage collector collects resource, it would automatically call the function gsl_XXX_free (or a chicken wrapper of it). Is that even possible? If it isn't could someone suggest a "schemish" approach to the problem?
[Prev in Thread] | Current Thread | [Next in Thread] |