[cffi-devel] wanted? finalization - automatic deallocation of foreign memory
Martin Simmons
martin at lispworks.com
Fri Jan 27 22:43:08 UTC 2006
>>>>> On Fri, 27 Jan 2006 17:10:55 +0100, "Hoehle, Joerg-Cyril" <Joerg-Cyril.Hoehle at t-systems.com> said:
>
> 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?
It might be better to do the finalization on the stream itself (you probably
want it the close the handle anyway).
__Martin
More information about the cffi-devel
mailing list