I suppose these questions better be directed to Marc:
a)
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.
Two questions:
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)?
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?
b)
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)
c)
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?
Thanks
Mikael