[cffi-devel] Re: CFFI malloc free
Luís Oliveira
luismbo at gmail.com
Mon Dec 19 16:37:09 UTC 2005
On 12/19/05, Hoehle, Joerg-Cyril <Joerg-Cyril.Hoehle at t-systems.com> wrote:
> This is exactly the pattern of :string+ptr, and it's embodied in
> tests/misc-types.lisp:deftest misc-types.string+ptr:
> a) return string and
> b) (foreign-free pointer)
> Is that testcase broken? "Just" non-portable?
I need to investigate this a bit further, but I think that right now
that testcase is indeed non-portable. Since not all Lisps use the
standard malloc/free to (de)allocate foreign memory. Allegro uses
aclmalloc(), for instance, so the standard free() on the C side won't
quite work on memory allocated by cffi:foreign-alloc.
> Well, since foreign-free's specification is to free only things allocated with foreign-alloc, maybe CFFI must export the general C free() as well?
Yes, I think so. The idea is to add an extra parameter to
foreign-alloc and foreign-free to specify whether the memory should be
allocated with malloc (and deallocated with free) or not.
--
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/
Equipa Portuguesa do Translation Project
http://www.iro.umontreal.ca/translation/registry.cgi?team=pt
More information about the cffi-devel
mailing list