<div dir="ltr">ok .. I will take a stab at it ... /ghc-6.8.2/libraries/base/Foreign/Marshal .... I am not so familiar with the ghc run-time model ... <br><br>V.<br><br><div class="gmail_quote">On Thu, Aug 7, 2008 at 1:26 AM, Galchin, Vasili <span dir="ltr">&lt;<a href="mailto:vigalchin@gmail.com">vigalchin@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div dir="ltr">In which directory are they?<br><font color="#888888"><br>Vasili</font><div><div>
</div><div class="Wj3C7c"><br><br><div class="gmail_quote">On Thu, Aug 7, 2008 at 12:58 AM, Bulat Ziganshin <span dir="ltr">&lt;<a href="mailto:bulat.ziganshin@gmail.com" target="_blank">bulat.ziganshin@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello Vasili,<br>
<br>
Thursday, August 7, 2008, 9:33:32 AM, you wrote:<br>
<br>
oh, it was my mistake. alloca behavior is completely defined by it&#39;s<br>
generic implementation:<br>
<br>
allocaBytes &nbsp; &nbsp; &nbsp;:: Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b<br>
allocaBytes size &nbsp;= bracket (mallocBytes size) free<br>
<br>
although GHC implementation is much more efficient<br>
<br>
btw, why you can&#39;t download ghc library sources and read them yourself??<br>
<div><div></div><div><br>
<br>
<br>
&gt; If I am correct, I cannot associate a ForeignPtr with alloca or<br>
&gt; allocaBytes object via &quot;newForeignPtr&quot; because the<br>
&gt; alloca/allocaBytes heap object will be GC&#39;d when I leave the<br>
&gt; function that allocated this object/. I.e. if I have a heap object<br>
&gt; that I want to live beyond a function invocation, I must be very careful in coding....<br>
&gt;<br>
&gt; Vasili<br>
<br>
&gt; On Thu, Aug 7, 2008 at 12:30 AM, Galchin, Vasili &lt;<a href="mailto:vigalchin@gmail.com" target="_blank">vigalchin@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; so Bulat ..<br>
<br>
&gt; &nbsp;&nbsp;&nbsp;&nbsp; You seem to be saying what I suspect ... i.e. if an<br>
&gt; allocaBytes call is inside a function, when the function is exited<br>
&gt; then the said heap object is GC&#39;d??<br>
<br>
&gt; Regards, Vasili<br>
&gt;<br>
<br>
&gt;<br>
<br>
&gt; On Thu, Aug 7, 2008 at 12:25 AM, Bulat Ziganshin<br>
&gt; &lt;<a href="mailto:bulat.ziganshin@gmail.com" target="_blank">bulat.ziganshin@gmail.com</a>&gt; wrote:<br>
&gt; &nbsp;Hello Vasili,<br>
&gt;<br>
<br>
&gt; &nbsp;Thursday, August 7, 2008, 9:13:43 AM, you wrote:<br>
&gt;<br>
&nbsp;&gt;&gt; &nbsp;&nbsp;&nbsp; What is the lifetime of various heap objects ... e.g. created by allocaBytes, alloca, etc?<br>
&gt;<br>
&gt;<br>
&gt; alloca/allocaBytes just mimicks stack allocation but actually allocates<br>
&gt; &nbsp;buffer in usual heap. this buffer lives while references to it exists<br>
&gt;<br>
&gt; &nbsp;on practice, it&#39;s usually gc&#39;ed by next minor GC<br>
&gt;<br>
&gt; &nbsp;--<br>
&gt; &nbsp;Best regards,<br>
&gt; &nbsp;&nbsp;Bulat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mailto:<a href="mailto:Bulat.Ziganshin@gmail.com" target="_blank">Bulat.Ziganshin@gmail.com</a><br>
&gt;<br>
&gt;<br>
<br>
&gt;<br>
<br>
&gt;<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div>Best regards,<br>
&nbsp;Bulat &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mailto:<a href="mailto:Bulat.Ziganshin@gmail.com" target="_blank">Bulat.Ziganshin@gmail.com</a><br>
<br>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>