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