-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 02/29/2012 01:29 PM, Thomas Chust wrote:
> Last but not least, passing structures as pointers makes memory > management for them explicit and that is a good thing in this case > because there is simply no way the FFI could automatically figure out > how the optimal memory management strategy for structures passed by > value should look like. For example, whether such a structure can be > allocated as an atomic block of memory or not is impossible to answer > without knowing what the functions producing and consuming instances of > the structure actually do. I slightly disagree here. A structure passed or returned by value is just shoved on the stack, maybe in registers if it's a small structure. There's no extra memory management required; merely some extra copying to copy from the Chicken-side foreign-type pointer into the appropriate bit of stack or registers, or back again for returned values. But, indeed, it's easy to do that in C as your distim demonstration shows; return values are only slightly harder as you'll need to allocate a struct and copy the result in, then return that pointer. ABS - -- Alaric Snell-Pym http://www.snell-pym.org.uk/alaric/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9ONY8ACgkQRgz/WHNxCGpVFQCdFmrrkp6RhMkQQNIaRtElcQUw At8An3tuScsj6vKNCi/CQDVVTeRR1ZHE =foQX -----END PGP SIGNATURE----- _______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
