<div dir="ltr"><div>There is a small difference though.</div><div>Spur alloc on 8 bytes boundary, while the OS might alloc on 16.</div><div>Believe it or not, depending on alignment, accelerated path can differ.</div><div>See <a href="https://github.com/nicolas-cellier-aka-nice/smallapack/issues/1">https://github.com/nicolas-cellier-aka-nice/smallapack/issues/1</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 21 mai 2020 à 20:38, Vanessa Freudenberg <<a href="mailto:vanessa@codefrau.net">vanessa@codefrau.net</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">The old object memory did not have pinning. So if you needed an unchanging address, you had to allocate it externally. </div><div dir="auto"><br></div><div dir="auto">With Spur’s pinned objects there is less need for external allocations, true. </div><div dir="auto"><br></div><div dir="auto">However, there is more risk of corrupting your object memory if the ByteArray is not large enough. Externally allocated memory is a little safer in that regard. </div><div dir="auto"><br></div><div dir="auto">Also, you may have to think more about what happens after image reload. Then again, that’s tricky with FFI either way. </div><div dir="auto"><br></div><div dir="auto">- Vanessa -</div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 21, 2020 at 11:30 Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" target="_blank">marcel.taeumel@hpi.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div id="gmail-m_-2840026108125255157m_2983219589379647037__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)">
                                        <div style="font-family:Arial">Hi Vanessa!</div><div style="font-family:Arial"><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 style="font-family:Arial"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div style="font-family:Arial"><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 style="font-family:Arial"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div style="font-family:Arial"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">So, is there any need for #newExternal and #free?</span></div><div style="font-family:Arial"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px"><br></span></div><div style="font-family:Arial"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Best,</span></div><div style="font-family:Arial"><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px">Marcel</span></div></div></div><div><div id="gmail-m_-2840026108125255157m_2983219589379647037__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div style="font-family:Arial"></div><blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-top:20px;margin-left:0px;padding-left:10px;font-family:Arial">
                        <p style="margin-top:10px;font-family:Arial;color:rgb(170,170,170)">Am 21.05.2020 20:03:40 schrieb Vanessa Freudenberg <<a href="mailto:vanessa@codefrau.net" style="font-family:Arial" target="_blank">vanessa@codefrau.net</a>>:</p><div style="font-family:Arial,Helvetica,sans-serif">
<div style="font-family:Arial,Helvetica,sans-serif"><br><div class="gmail_quote" style="font-family:Arial,Helvetica,sans-serif"><div dir="ltr" class="gmail_attr" style="font-family:Arial,Helvetica,sans-serif">On Thu 21. May 2020 at 00:30, Marcel Taeumel <<a href="mailto:marcel.taeumel@hpi.de" style="font-family:Arial,Helvetica,sans-serif" target="_blank">marcel.taeumel@hpi.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;font-family:Arial,Helvetica,sans-serif"><div id="gmail-m_-2840026108125255157m_2983219589379647037m_1108347946976773069__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><br><div style="font-family:Arial"><br></div><div style="font-family:Arial">Latest thing -- that's why this question about ByteArrays -- was how to re-think this code:</div><div style="font-family:Arial"><br></div><div style="font-family:Arial">MyStruct foo;</div><div style="font-family:Arial">someFunctionFillsMyStruct(&foo);</div><div style="font-family:Arial"><br></div><div style="font-family:Arial">Into this code:</div><div style="font-family:Arial"><br></div><div style="font-family:Arial">foo := MyStruct new. "handle is ByteArray"</div><div style="font-family:Arial">self apiSomeFunctionFillsMyStruct: foo.</div><div style="font-family:Arial"><br></div><div style="font-family:Arial">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" style="font-family:Arial,Helvetica,sans-serif"><br></div><div dir="auto" style="font-family:Arial,Helvetica,sans-serif">I was under the impression that is exactly how it works.</div><div dir="auto" style="font-family:Arial,Helvetica,sans-serif"><br></div><div dir="auto" style="font-family:Arial,Helvetica,sans-serif">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" style="font-family:Arial,Helvetica,sans-serif"><br></div><div dir="auto" style="font-family:Arial,Helvetica,sans-serif">- Vanessa -</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;font-family:Arial,Helvetica,sans-serif"><div id="gmail-m_-2840026108125255157m_2983219589379647037m_1108347946976773069__MailbirdStyleContent" style="font-size:10pt;font-family:Arial;color:rgb(0,0,0)"><div style="font-family:Arial"></div></div></blockquote></div></div>
</div></blockquote>
                                        </div></div><br>
</blockquote></div></div>
<br>
</blockquote></div>