|
From: | felix winkelmann |
Subject: | Re: [Chicken-users] Returning non-zero terminated strings from foreign code |
Date: | Sun, 4 Mar 2007 14:27:39 +0100 |
On 3/4/07, Peter Schuller <address@hidden> wrote:
Hello, Given some C code that malloc:s a buffer and puts some arbitrary data (including potentially zeroes) into it, I want to convert that into a Scheme string. Is there an idiomatic way to do this? I had a look at foreign-lambda* to see how c-string return values are handled, but it quickly gets pretty involved with Chicken internals that I'm not yet ready to tackle...
The simplest solution I can come up with right now is to use "c-pointer" as result type and "(move-memory! <ptr> <string-of-the-right-length> <count>)" the data into a separately allocated string. cheers, felix
[Prev in Thread] | Current Thread | [Next in Thread] |