<br><br><div class="gmail_quote">On Sun, Jun 19, 2011 at 1:32 PM, Stephen Blackheath [to GHC-iPhone] <span dir="ltr">&lt;<a href="mailto:likeliest.complexions.stephen@blacksapphire.com">likeliest.complexions.stephen@blacksapphire.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">David,<br>
<br>
In GHC-iPhone the number of function pointers that are allowed to be active for a given function is limited, but you can change the size of the limit.  This is documented in<br>
<br></blockquote><div><br>Steve,<br><br>Yep... I understand that there are not an unlimited number of function pointers.  However, the function that I wrote was &quot;supposed&quot; to automatically release the function:<br>
<br>runOnMain :: IO () -&gt; IO ()<br>runOnMain todo = do<br>                  func &lt;- funky<br>                  dispatchFunc func<br>
  where funky =  mkStrCB $ \v -&gt; do                              <br>                                   todo<br><div id=":23h">                                   func &lt;- funky<br>                                   freeHaskellFunPtr func<br>
<br>Note the freeHaskellFunPtr function call at the end of the lambda.<br><br>I&#39;m thinking that the &quot;func &lt;- funky&quot; line is being treated as a recursive call and I&#39;m also thinking that this is a limitation of my understanding the magic of lazy evaluation.<br>
<br>So, please let me rephrase my question:<br><br>How do I get the pointer to a wrapper function so that the pointer can be used within the wrapped function itself?<br><br>I have worked around the particular issue by making a call to freeHaskellFunPtr in the Objective-C code that invokes the function.  It&#39;s less optimal that being able to have the Haskell code be able to auto-free the function pointer after the function is invoked.<br>
<br>Thanks,<br><br>David<br></div><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<a href="http://projects.haskell.org/ghc-iphone/downloads/GHC-iPhone.pdf" target="_blank">http://projects.haskell.org/<u></u>ghc-iphone/downloads/GHC-<u></u>iPhone.pdf</a><br>
<br>
on p5 under &#39;Pool sizes for foreign function &quot;wrapper&quot; callbacks&#39;.<br>
<br>
<br>
Steve<div><div></div><div class="h5"><br>
<br>
On 18/06/11 11:29, David Pollak wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
Howdy,<br>
<br>
I tried to build a function that would create an auto-freeing function<br>
pointer:<br>
<br>
runOnMain :: IO () -&gt; IO ()<br>
runOnMain todo = do<br>
                   func &lt;- funky<br>
                   dispatchFunc func<br>
   where funky =  mkStrCB $ \v -&gt; do<br>
                                    todo<br>
                                    func &lt;- funky<br>
                                    freeHaskellFunPtr func<br>
<br>
Unfortunately, I wind up getting:<br>
  internal error: iPhoneCreateAdjustor - adjustor pool &#39;Main_d2K2&#39; is<br>
empty (capacity 32)<br>
     (GHC version 6.10.4-iphone-simulator for i386_apple_darwin)<br>
<br>
I&#39;m not sure why, but I suspect that funky is being called recursively<br>
and thus stuff is never being freed.<br>
<br>
Any hints as to the issue and solutions?<br>
<br>
Thanks,<br>
<br>
David<br>
<br>
<br>
--<br>
Lift, the simply functional web framework <a href="http://liftweb.net" target="_blank">http://liftweb.net</a><br>
Simply Lift <a href="http://simply.liftweb.net" target="_blank">http://simply.liftweb.net</a><br>
Follow me: <a href="http://twitter.com/dpp" target="_blank">http://twitter.com/dpp</a><br>
Blog: <a href="http://goodstuff.im" target="_blank">http://goodstuff.im</a><br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
iPhone mailing list<br>
<a href="mailto:iPhone@haskell.org" target="_blank">iPhone@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/iphone" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/iphone</a><br>
</blockquote>
<br>
______________________________<u></u>_________________<br>
iPhone mailing list<br>
<a href="mailto:iPhone@haskell.org" target="_blank">iPhone@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/iphone" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/iphone</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Lift, the simply functional web framework <a href="http://liftweb.net" target="_blank">http://liftweb.net</a><div>Simply Lift <a href="http://simply.liftweb.net" target="_blank">http://simply.liftweb.net</a><br>
Follow me: <a href="http://twitter.com/dpp" target="_blank">http://twitter.com/dpp</a><br>Blog: <a href="http://goodstuff.im" target="_blank">http://goodstuff.im</a><br></div><br>