[cffi-devel] wanted? finalization - automatic deallocation of foreign memory

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Fri Jan 27 16:10:55 UTC 2006


Hi,

Another thing not yet covered by CFFI is finalization: one may wish
for the foreign entity in the cl+ssl stream object to be free'd even
when the stream is never closed by the application.  Here again,
implementations vary: Corman always adds a FREE finalizer to
ct:malloc.  CLISP does not (doing so would even break its :malloc
parameter mode, where the foreign side does the free).

Maybe finalizable foreign-alloc is something that CFFI
should offer as an additional keyword?

Then of course, one must think about what happens when foreign-free is
called.  I'd expect Corman to detect that, since there's not even a
possibility to not have that automatic finalizer.  CLISP could use
invalid pointers to detect the duplicate free, but I'd expect
implementations where raw pointers (or integers, e.g. Allegro) are
used to not be able to detect duplicate free.  Therefore, CFFI must
probably specify that free is not allowed by the user anymore when
(foreign-alloc :finalize t) is used.

Hmm, with Allegro having pointers as ints, it will be hard to finalize
that... Maybe they feature something else?

Regards,
	Jörg Höhle



More information about the cffi-devel mailing list