[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GC-related question



I'm trying to write an MzScheme extension that provides bindings to an
external library, but I don't quite understand how to deal with the
garbage collector. This library uses normal C malloc()'s for its
allocation, and it would be Bad to lose the pointers to the structures
it creates (since they're rather expensive to allocate). I'll be adding
a new Scheme type to represent these structures.

I want the Scheme representations of these structures to be GC'ed
normally (so that the bindings can be conveniently used in
functional-style programs), but I need to be able to free the data they
represent before they are lost. How can I do this?

The scheme_register_finalizer function looks something like what I need,
but I'm not sure.

Thanks!
-John