[Top][All Lists]

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

Re: [Chicken-users] howto return a list from a c-function

From: John Cowan
Subject: Re: [Chicken-users] howto return a list from a c-function
Date: Wed, 4 Apr 2007 17:02:35 -0400
User-agent: Mutt/1.5.13 (2006-08-11)

felix winkelmann scripsit:

> I will try to come up with a usable implementation for the
> other direction, passing string-lists to C, but I'm not sure
> where to allocate the storage for the list, and what to do
> for callbacks that might trigger GC. Perhaps allocate
> an array via alloca()? Any ideas are welcome.

I suggest that you use the same general machinery as c-string and
c-string*, except that instead of a single null-terminated string
you have a NULL-terminated array immediately followed by null-terminated
strings.  So when passing these to C, malloc() a single block for them
(you know all the sizes in advance), and if the result type is
c-string-list*, then after copying the strings, simply cast
the char** to void* and free() it.

John Cowan    address@hidden
Half the lies they tell about me are true.
        -- Tallulah Bankhead, American actress

reply via email to

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