<div dir="ltr">Hi!<div><br></div><div>I suppose these questions better be directed to Marc:<div><br></div><div>a)</div><div>On many occassions, FFI:s need to pass external libraries structures. These are variables passed by value (ints, floats, bools), and variables passed as pointers, that is, strings and structures.</div>

<div><br></div><div>Two questions:</div><div><br></div><div>First off, I presume that UTF-8-string argument values passed to a c-lambda are by default allocated until function return. How can one make so that such an argument value continues to exist after the C function returns (i.e. increase reference count)? At the time one wants to discard the string, how is that done (i.e. decrease reference count)?</div>

<div><br></div><div>Second, on many occasions, one needs malloc/free functionality in FFI code. Do you recommend one to use some Gambit-internal function to get the functional equivalent, or to go with a malloc such as tcmalloc?</div>

<div><br></div><div>b)</div><div>Do c-lambda invocation require a trampoline, so that there's a trampoline cost involved in each Scheme-to-C call? (Each taking ~0.5*10^-8 seconds, afaik)</div><div><br></div><div>c)</div>

<div>Is there one particular practice you recommend for FFI functions to return multiple return values, in a performant way? Can you give a code example that returns bool, unsigned 32- and 64-bit integer, char* containing UTF-8 string, and byte buffer returned as u8vector?</div>
<div><br></div><div>Thanks</div><div>Mikael</div><div><br></div></div></div>