Page 1 of 1

avoiding releasing foreign types

Posted: Sat Nov 14, 2015 10:08 pm
by monte
Hi

I'm wondering if we can add a generic way to pass the fact that a foreign value shouldn't be released. I'm encountering a crash on a function that returns a pointer to a static string. At the moment it seems doimport just has a hard coded true for release.

Cheers

Monte

Re: avoiding releasing foreign types

Posted: Tue Dec 01, 2015 9:52 am
by LCMark
@monte: At the moment the FFI interface has no idea of 'give, borrow or take' - in this instance you want to 'borrow' the value from the native function. Unfortunately, the only way to do this at the moment is to return a Pointer, and then use MCStringCreateWithCString directly as a foreign binding.

Re: avoiding releasing foreign types

Posted: Tue Dec 01, 2015 11:53 am
by monte
OK, I was thinking it might be possible to add some syntax to the foreign handler definitions to declare ownership or at least whether it should be freed.