[UFFI-Devel] free-foreign-object vs. free Issues
Kevin Rosenberg
kevin at rosenberg.net
Wed Sep 1 09:32:15 MDT 2004
Martin Ginkel wrote:
> In the doc of uffi this case is described:
> http://uffi.b9.com/manual/strings.html
Yes, it is.
> I tried the free-foreign-object on the string, and it worked fine in
> CMUCL. But in Allegro (6.2-linux) it apparently doesn't free anything,
> but also does not throw an error.
> The solution was to use the "free" from libc after converting the
> string.
You are correct. Reding the AllegroCL 7.0beta documentation, memory
allocated with C's malloc should be freed with AllegroCL's ff:free
rather than ff:free-fobject.
> In my opinion the model behind this could be:
> If you allocate a foreign object in Lisp and give it to C, you should
> free this with free-foreign-object. At least in Allegro this seems to
> work in a different heap space. But if C has allocated something, you
> should free with libc::free.
> Are there Issues with using libc directly in other Platforms?
I don't think there are any issues with using C's free on other
platforms. But, as usual, it's important to test.
I'll update the documentation about freeing memory allocated by C.
--
Kevin Rosenberg
kevin at rosenberg.net
More information about the UFFI-Devel
mailing list