<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000">
                                        <div>Hi Vanessa!</div><div><br></div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">You just need to make a ByteArray that is large enough to hold the struct. Passing that to FFI will pass a pointer to the first byte of the ByteArray. The API call would fill the ByteArray. So it should Just Work.</span><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Ah, I thought so. But I did not verify it by looking at the FFI sources. :-)</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">So, is there any need for #newExternal and #free?</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Best,</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Marcel</span></div><div class="mb_sig"></div><blockquote class="history_container" type="cite" style="border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;">
                        <p style="color: #AAAAAA; margin-top: 10px;">Am 21.05.2020 20:03:40 schrieb Vanessa Freudenberg <vanessa@codefrau.net>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu 21. May 2020 at 00:30, Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de">marcel.taeumel@hpi.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id="m_1108347946976773069__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000"><br><div><br></div><div>Latest thing -- that's why this question about ByteArrays -- was how to re-think this code:</div><div><br></div><div>MyStruct foo;</div><div>someFunctionFillsMyStruct(&foo);</div><div><br></div><div>Into this code:</div><div><br></div><div>foo := MyStruct new. "handle is ByteArray"</div><div>self apiSomeFunctionFillsMyStruct: foo.</div><div><br></div><div>Meaning, what whould be on the stack in C, can conveniently be hold in Squeak's object memory to be shared across Squeak processes and applications.</div></div></blockquote><div dir="auto"><br></div><div dir="auto">I was under the impression that is exactly how it works.</div><div dir="auto"><br></div><div dir="auto">You just need to make a ByteArray that is large enough to hold the struct. Passing that to FFI will pass a pointer to the first byte of the ByteArray. The API call would fill the ByteArray. So it should Just Work.</div><div dir="auto"><br></div><div dir="auto">- Vanessa -</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id="m_1108347946976773069__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000"><div></div></div></blockquote></div></div>
</div></blockquote>
                                        </div></body>