On 2/5/07, felix winkelmann <[EMAIL PROTECTED]> wrote:
Another option would be to create a GC root (CHICKEN_new_gc_root)
and keep it on the C-side (you have to pass the argument string as
a scheme-object, then create the GC-root from it). Later, you can
access the gc root (CHICKEN_gc_root_ref) and use the string. The
gc root will be updated on every garbage collection. You just have
to make sure you free it eventually (or just reuse it).
I may try that, but at the moment I've opted for a solution managed on
the Scheme side.
It's something like this (in tinyclos)
(define-method (curl-evict (c <curl>) name)
(let* ((obj (slot-ref c name))
(evictee (object-evict obj)))
(slot-set! c '%evictees (cons evictee (slot-ref c '%evictees)))
evictee))
The slot %evictees is initially an empty list, and grows with each
eviction so that I can keep a tab on all objects formerly belonging to
the item that have been evicted.
The finalizer for the <curl> object is simply:
(define (curl-finalize! c)
(map object-release (slot-ref c '%evictees)))
So now if I need to pass a string parameter to C I do this:
(case type
...
((c-string) (curl-easy-set-option-c-string! rc key
(curl-evict c name)))
...
_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users