<div dir="ltr">Thank you Duncan for your example. I will also read the RSA code.<br><br>Regards, Vasili<br><br><br><div class="gmail_quote">On Sun, Jul 20, 2008 at 6:51 AM, Duncan Coutts &lt;<a href="mailto:duncan.coutts@worc.ox.ac.uk">duncan.coutts@worc.ox.ac.uk</a>&gt; 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 class="Ih2E3d"><br>
On Sat, 2008-07-19 at 23:55 -0500, Galchin, Vasili wrote:<br>
&gt; yes Duncan I am trying to pass-by-value. I am familiar with<br>
&gt; ForeignPtr; however, I don&#39;t comprehend what you and Brandon are<br>
&gt; suggesting to do. Could either of you provide a code illustration or<br>
&gt; point at existing code to illustrate your approach?<br>
<br>
</div>Take a look at John Meacham&#39;s RSA example.<br>
<br>
So at the moment you&#39;re using using Storable and a Haskell record, say:<br>
<br>
data AIOCB = AIOCB {<br>
 &nbsp; &nbsp;...<br>
 &nbsp;}<br>
<br>
and we&#39;re suggesting instead:<br>
<br>
newtype AIOCB = AIOCB (ForeignPtr AIOCB)<br>
<br>
then to access a member use hsc2hs:<br>
<br>
getBlah :: AIOCB -&gt; IO Blah<br>
getBlah (AIOCB fptr) =<br>
 &nbsp;withForeignPtr fptr $ \ptr -&gt; {# peek aiocb,blah #} ptr<br>
<br>
So you only access the parts you need and keep the aiocb C struct<br>
allocated on the heap (use mallocForeignPtr).<br>
<font color="#888888"><br>
Duncan<br>
<br>
</font></blockquote></div><br></div>