[Cuis-dev] [FFI] Passing a GC collected record to C Code

Philip Bernhart philip.bernhart at posteo.de
Mon Jun 24 22:46:03 PDT 2019


Hi Ken,

thanks for the link. One question regarding the FFI tests,
is FFIPluginTests>>testPointers leaking memory? As the
ffiTestPointers function mallocs a result pointer structure
and returns the pointer to it back to the vm.

And if not, how does the VM know if the pointer it receives
can be freed / garbage collected?

I assume that my approach of creating an ExternalAddress with
gcallocate is atleast to me clearer.


Thanks,
Philip



ken.dickey at whidbey.com writes:

> On 2019-06-23 11:51, Philip Bernhart via Cuis-dev wrote:
>> Hi,
>> 
>> how do I pass a struct, which is supposed to be
>> fully lying in the memory space of the VM to some
>> external C code which then copies data into that
>> struct and does nothing with it afterwards?
>
> Feature require: #'FFITests'.
>
> Then browse, e.g. FFIPluginTests>>testBiggerStruct
>
> C code corresponding to the tests is in the OpenSmalltalk git 
> repository, e.g.:
>
> https://github.com/OpenSmalltalk/opensmalltalk-vm/blob/Cog/platforms/Cross/plugins/SqueakFFIPrims/sqFFITestFuncs.c
>
> HTH,
> -KenD


More information about the Cuis-dev mailing list