chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] FFI and allocation/garbage collection


From: John Cowan
Subject: Re: [Chicken-users] FFI and allocation/garbage collection
Date: Wed, 12 Jul 2006 14:55:42 -0400
User-agent: Mutt/1.3.28i

Alex scripsit:

> I was wondering how the FFI wraps C functions which return strings. When
> the C strings are converted into Scheme strings, is the data copied (so
> that the Scheme string is an ordinary GC-able Scheme object), or does
> the Scheme string share the C string's data, so that automatic GC is not
> possible?

There are three cases, depending on what type a foreign-lambda or
foreign-lambda* returns:

        c-string: The string contents are copied by Chicken.

        c-string*: The string contents are copied by Chicken
                and then freed (this is useful when the C side
                mallocs a string).

        c-pointer: Chicken gets a pointer object rather than
                a string object (the lolevel unit has tools
                for manipulating these) and the C side is
                responsible for keeping the string allocated.

-- 
Income tax, if I may be pardoned for saying so,         John Cowan
is a tax on income.  --Lord Macnaghten (1901)           address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]