<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 <<a href="mailto:duncan.coutts@worc.ox.ac.uk">duncan.coutts@worc.ox.ac.uk</a>> 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>
> yes Duncan I am trying to pass-by-value. I am familiar with<br>
> ForeignPtr; however, I don't comprehend what you and Brandon are<br>
> suggesting to do. Could either of you provide a code illustration or<br>
> point at existing code to illustrate your approach?<br>
<br>
</div>Take a look at John Meacham's RSA example.<br>
<br>
So at the moment you're using using Storable and a Haskell record, say:<br>
<br>
data AIOCB = AIOCB {<br>
...<br>
}<br>
<br>
and we're suggesting instead:<br>
<br>
newtype AIOCB = AIOCB (ForeignPtr AIOCB)<br>
<br>
then to access a member use hsc2hs:<br>
<br>
getBlah :: AIOCB -> IO Blah<br>
getBlah (AIOCB fptr) =<br>
withForeignPtr fptr $ \ptr -> {# 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>