chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] What happens to a (non-simple) Scheme object sent to


From: Thomas Christian Chust
Subject: Re: [Chicken-users] What happens to a (non-simple) Scheme object sent to a foreign function?
Date: Sun, 04 Feb 2007 14:11:42 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070111 SeaMonkey/1.1

Tony Sidaway wrote:

> I'm sending a Scheme string to a foreign (C) library as a c-string.
> I also send it the address of a Scheme procedure created as
> define-external--this address is sent as a c-pointer.
> [...]

Hello,

the address of the C function wrapping the define-external'ed Scheme
procedure is unproblematic, because it will never change. The pointer to
the C string data may become invalid, though, once the program returns
from the library call. In order to make this safe, you would have to
duplicate the string in the C heap (for example using strdup) or you
would have to create a non-garbage-collected copy of the Scheme string
(for example using object-copy) to pass that to the library routine. In
either case you would have to release the string data later on when it
is no longer needed.

cu,
Thomas





reply via email to

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