<p>Thanks, Mikael.</p>
<p>If you use Car, Cdr, etc from C, you are actually at the same point, traversing the structure. That's fine for lists, but what about vectors?<br>
I would like to use memcpy, but for that:<br>
- i must respect alignment, padding or chunks if they happen to exist in Gambit's vectors implementation.<br>
- i must know the array pointer, in case is stored after some Gambit-specific data, such as type tags.</p>
<p>Thanks again for your answer,</p>
<p>Álvaro<br>
</p>
<div class="gmail_quote">El 12/04/2013 12:37, "Mikael" <<a href="mailto:mikael.rcv@gmail.com">mikael.rcv@gmail.com</a>> escribió:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Alvaro,<div><br></div><div>You can traverse all Scm structures from C.</div><div><br></div><div>You have typecheckers, car, cdr, vector-ref, accessors for all the specialized vector types and so on.</div><div><br></div>


<div>In the current Gambit version, from all I know, using these works perfectly.</div><div><br></div><div>As soon as Gambit goes SMP, this may be a slightly other story and only the objects specifically allocated with ___STILL may be safe to use, we'll see when we get there. What could be an issue would be that the GC would trig during your C call and change all the other object references to an object and then its physical memory location, and you'd be using the old one in your C code.</div>


<div><br></div><div>Do you have a specific question or problem to solve?</div><div><br></div><div>Brgds,</div><div>Mikael<br><br><div class="gmail_quote">2013/4/12 Álvaro Castro-Castilla <span dir="ltr"><<a href="mailto:alvaro.castro.castilla@gmail.com" target="_blank">alvaro.castro.castilla@gmail.com</a>></span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There is one thing that I've been meaning to ask for a long time now.<div><br></div><div>I see most of the people tend to create arrays in C by malloc/___alloc_rc and then assigning values by iterating over them via a setter function (also defined with c-lambda).</div>




<div>Isn't there a way to directly do this with a memcpy operation? Wouldn't that be faster?</div><div><br></div><div>I understand that Gambit's heap and C's heap are separate, and you need to copy from one another in order to avoid GC touching any of FFI-created memory. But is it possible to improve this process using some sort of C function/macro from Gambit?</div>




<div><br></div><div>I really can't find any code examples or reference for this.</div><div><br></div><div>Thank you very much.</div><span><font color="#888888"><div><br></div><div>Álvaro</div></font></span></div>


<br>_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
<br></blockquote></div><br></div>
</blockquote></div>