Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 2273

ghc-7.4.2-4.mga5.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Foreign.ForeignPtr.Safe</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Foreign-ForeignPtr-Safe.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">base-4.5.1.0: Basic libraries</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>provisional</td></tr><tr><th>Maintainer</th><td>ffi@haskell.org</td></tr><tr><th>Safe Haskell</th><td>Trustworthy</td></tr></table><p class="caption">Foreign.ForeignPtr.Safe</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Finalised data pointers
</a><ul><li><a href="#g:2">Basic operations
</a></li><li><a href="#g:3">Low-level operations
</a></li><li><a href="#g:4">Allocating managed memory
</a></li></ul></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>The <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> type and operations.  This module is part of the
 Foreign Function Interface (FFI) and will usually be imported via
 the <a href="Foreign.html">Foreign</a> module.
</p><p>Safe API Only.
</p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span>  <a href="#t:ForeignPtr">ForeignPtr</a> a</li><li class="src short"><span class="keyword">type</span> <a href="#t:FinalizerPtr">FinalizerPtr</a> a = <a href="Foreign-Ptr.html#t:FunPtr">FunPtr</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a>)</li><li class="src short"><span class="keyword">type</span> <a href="#t:FinalizerEnvPtr">FinalizerEnvPtr</a> env a = <a href="Foreign-Ptr.html#t:FunPtr">FunPtr</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> env -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a>)</li><li class="src short"><a href="#v:newForeignPtr">newForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerPtr">FinalizerPtr</a> a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li><li class="src short"><a href="#v:newForeignPtr_">newForeignPtr_</a> ::  <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li><li class="src short"><a href="#v:addForeignPtrFinalizer">addForeignPtrFinalizer</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerPtr">FinalizerPtr</a> a -&gt; <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:newForeignPtrEnv">newForeignPtrEnv</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerEnvPtr">FinalizerEnvPtr</a> env a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> env -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li><li class="src short"><a href="#v:addForeignPtrFinalizerEnv">addForeignPtrFinalizerEnv</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerEnvPtr">FinalizerEnvPtr</a> env a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> env -&gt; <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:withForeignPtr">withForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> b) -&gt; <a href="System-IO.html#t:IO">IO</a> b</li><li class="src short"><a href="#v:finalizeForeignPtr">finalizeForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:touchForeignPtr">touchForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:castForeignPtr">castForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> b</li><li class="src short"><a href="#v:mallocForeignPtr">mallocForeignPtr</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li><li class="src short"><a href="#v:mallocForeignPtrBytes">mallocForeignPtrBytes</a> ::  <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li><li class="src short"><a href="#v:mallocForeignPtrArray">mallocForeignPtrArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li><li class="src short"><a href="#v:mallocForeignPtrArray0">mallocForeignPtrArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</li></ul></div><div id="interface"><h1 id="g:1">Finalised data pointers
</h1><div class="top"><p class="src"><span class="keyword">data</span>  <a name="t:ForeignPtr" class="def">ForeignPtr</a> a </p><div class="doc"><p>The type <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> represents references to objects that are
 maintained in a foreign language, i.e., that are not part of the
 data structures usually managed by the Haskell storage manager.
 The essential difference between <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code>s and vanilla memory
 references of type <code>Ptr a</code> is that the former may be associated
 with <em>finalizers</em>. A finalizer is a routine that is invoked when
 the Haskell storage manager detects that - within the Haskell heap
 and stack - there are no more references left that are pointing to
 the <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code>.  Typically, the finalizer will, then, invoke
 routines in the foreign language that free the resources bound by
 the foreign object.
</p><p>The <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> is parameterised in the same way as <code><a href="Foreign-Ptr.html#t:Ptr">Ptr</a></code>.  The
 type argument of <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> should normally be an instance of
 class <code><a href="Foreign-Storable.html#t:Storable">Storable</a></code>.
</p></div><div class="subs instances"><p id="control.i:ForeignPtr" class="caption collapser" onclick="toggleSection('i:ForeignPtr')">Instances</p><div id="section.i:ForeignPtr" class="show"><table><tr><td class="src"><a href="Data-Typeable-Internal.html#t:Typeable1">Typeable1</a> <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Eq.html#t:Eq">Eq</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Typeable-Internal.html#t:Typeable">Typeable</a> a =&gt; <a href="Data-Data.html#t:Data">Data</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ord.html#t:Ord">Ord</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Text-Show.html#t:Show">Show</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:FinalizerPtr" class="def">FinalizerPtr</a> a = <a href="Foreign-Ptr.html#t:FunPtr">FunPtr</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a>)</p><div class="doc"><p>A finalizer is represented as a pointer to a foreign function that, at
 finalisation time, gets as an argument a plain pointer variant of the
 foreign pointer that the finalizer is associated with.
</p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:FinalizerEnvPtr" class="def">FinalizerEnvPtr</a> env a = <a href="Foreign-Ptr.html#t:FunPtr">FunPtr</a> (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> env -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a>)</p></div><h2 id="g:2">Basic operations
</h2><div class="top"><p class="src"><a name="v:newForeignPtr" class="def">newForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerPtr">FinalizerPtr</a> a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>Turns a plain memory reference into a foreign pointer, and
 associates a finalizer with the reference.  The finalizer will be
 executed after the last reference to the foreign object is dropped.
 There is no guarantee of promptness, however the finalizer will be
 executed before the program exits.
</p></div></div><div class="top"><p class="src"><a name="v:newForeignPtr_" class="def">newForeignPtr_</a> ::  <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>Turns a plain memory reference into a foreign pointer that may be
 associated with finalizers by using <code><a href="Foreign-ForeignPtr-Safe.html#v:addForeignPtrFinalizer">addForeignPtrFinalizer</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:addForeignPtrFinalizer" class="def">addForeignPtrFinalizer</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerPtr">FinalizerPtr</a> a -&gt; <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>This function adds a finalizer to the given foreign object.  The
 finalizer will run <em>before</em> all other finalizers for the same
 object which have already been registered.
</p></div></div><div class="top"><p class="src"><a name="v:newForeignPtrEnv" class="def">newForeignPtrEnv</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerEnvPtr">FinalizerEnvPtr</a> env a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> env -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>This variant of <code><a href="Foreign-ForeignPtr-Safe.html#v:newForeignPtr">newForeignPtr</a></code> adds a finalizer that expects an
 environment in addition to the finalized pointer.  The environment
 that will be passed to the finalizer is fixed by the second argument to
 <code><a href="Foreign-ForeignPtr-Safe.html#v:newForeignPtrEnv">newForeignPtrEnv</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:addForeignPtrFinalizerEnv" class="def">addForeignPtrFinalizerEnv</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:FinalizerEnvPtr">FinalizerEnvPtr</a> env a -&gt; <a href="Foreign-Ptr.html#t:Ptr">Ptr</a> env -&gt; <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Like <code><a href="Foreign-ForeignPtr-Safe.html#v:addForeignPtrFinalizerEnv">addForeignPtrFinalizerEnv</a></code> but allows the finalizer to be
 passed an additional environment parameter to be passed to the
 finalizer.  The environment passed to the finalizer is fixed by the
 second argument to <code><a href="Foreign-ForeignPtr-Safe.html#v:addForeignPtrFinalizerEnv">addForeignPtrFinalizerEnv</a></code>
</p></div></div><div class="top"><p class="src"><a name="v:withForeignPtr" class="def">withForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; (<a href="Foreign-Ptr.html#t:Ptr">Ptr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> b) -&gt; <a href="System-IO.html#t:IO">IO</a> b</p><div class="doc"><p>This is a way to look at the pointer living inside a
 foreign object.  This function takes a function which is
 applied to that pointer. The resulting <code><a href="System-IO.html#t:IO">IO</a></code> action is then
 executed. The foreign object is kept alive at least during
 the whole action, even if it is not used directly
 inside. Note that it is not safe to return the pointer from
 the action and use it after the action completes. All uses
 of the pointer should be inside the
 <code><a href="Foreign-ForeignPtr-Safe.html#v:withForeignPtr">withForeignPtr</a></code> bracket.  The reason for
 this unsafeness is the same as for
 <code><a href="Foreign-ForeignPtr-Unsafe.html#v:unsafeForeignPtrToPtr">unsafeForeignPtrToPtr</a></code> below: the finalizer
 may run earlier than expected, because the compiler can only
 track usage of the <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> object, not
 a <code><a href="Foreign-Ptr.html#t:Ptr">Ptr</a></code> object made from it.
</p><p>This function is normally used for marshalling data to
 or from the object pointed to by the
 <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code>, using the operations from the
 <code><a href="Foreign-Storable.html#t:Storable">Storable</a></code> class.
</p></div></div><div class="top"><p class="src"><a name="v:finalizeForeignPtr" class="def">finalizeForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>Causes the finalizers associated with a foreign pointer to be run
 immediately.
</p></div></div><h2 id="g:3">Low-level operations
</h2><div class="top"><p class="src"><a name="v:touchForeignPtr" class="def">touchForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="System-IO.html#t:IO">IO</a> <a href="../ghc-prim-0.2.0.0/GHC-Tuple.html#t:-40--41-">()</a></p><div class="doc"><p>This function ensures that the foreign object in
 question is alive at the given place in the sequence of IO
 actions. In particular <code><a href="Foreign-ForeignPtr.html#v:withForeignPtr">withForeignPtr</a></code>
 does a <code><a href="Foreign-ForeignPtr-Safe.html#v:touchForeignPtr">touchForeignPtr</a></code> after it
 executes the user action.
</p><p>Note that this function should not be used to express dependencies
 between finalizers on <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code>s.  For example, if the finalizer
 for a <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> <code>F1</code> calls <code><a href="Foreign-ForeignPtr-Safe.html#v:touchForeignPtr">touchForeignPtr</a></code> on a second
 <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> <code>F2</code>, then the only guarantee is that the finalizer
 for <code>F2</code> is never started before the finalizer for <code>F1</code>.  They
 might be started together if for example both <code>F1</code> and <code>F2</code> are
 otherwise unreachable, and in that case the scheduler might end up
 running the finalizer for <code>F2</code> first.
</p><p>In general, it is not recommended to use finalizers on separate
 objects with ordering constraints between them.  To express the
 ordering robustly requires explicit synchronisation using <code>MVar</code>s
 between the finalizers, but even then the runtime sometimes runs
 multiple finalizers sequentially in a single thread (for
 performance reasons), so synchronisation between finalizers could
 result in artificial deadlock.  Another alternative is to use
 explicit reference counting.
</p></div></div><div class="top"><p class="src"><a name="v:castForeignPtr" class="def">castForeignPtr</a> ::  <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a -&gt; <a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> b</p><div class="doc"><p>This function casts a <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code>
 parameterised by one type into another type.
</p></div></div><h2 id="g:4">Allocating managed memory
</h2><div class="top"><p class="src"><a name="v:mallocForeignPtr" class="def">mallocForeignPtr</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>Allocate some memory and return a <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> to it.  The memory
 will be released automatically when the <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> is discarded.
</p><p><code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code> is equivalent to
</p><pre>    do { p &lt;- malloc; newForeignPtr finalizerFree p }
</pre><p>although it may be implemented differently internally: you may not
 assume that the memory returned by <code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code> has been
 allocated with <code><a href="Foreign-Marshal-Alloc.html#v:malloc">malloc</a></code>.
</p><p>GHC notes: <code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code> has a heavily optimised
 implementation in GHC.  It uses pinned memory in the garbage
 collected heap, so the <code><a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a></code> does not require a finalizer to
 free the memory.  Use of <code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code> and associated
 functions is strongly recommended in preference to <code>newForeignPtr</code>
 with a finalizer.
</p></div></div><div class="top"><p class="src"><a name="v:mallocForeignPtrBytes" class="def">mallocForeignPtrBytes</a> ::  <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>This function is similar to <code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code>, except that the
 size of the memory required is given explicitly as a number of bytes.
</p></div></div><div class="top"><p class="src"><a name="v:mallocForeignPtrArray" class="def">mallocForeignPtrArray</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>This function is similar to <code><a href="Foreign-Marshal-Array.html#v:mallocArray">mallocArray</a></code>,
 but yields a memory area that has a finalizer attached that releases
 the memory area.  As with <code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code>, it is not guaranteed that
 the block of memory was allocated by <code><a href="Foreign-Marshal-Alloc.html#v:malloc">malloc</a></code>.
</p></div></div><div class="top"><p class="src"><a name="v:mallocForeignPtrArray0" class="def">mallocForeignPtrArray0</a> :: <a href="Foreign-Storable.html#t:Storable">Storable</a> a =&gt; <a href="Data-Int.html#t:Int">Int</a> -&gt; <a href="System-IO.html#t:IO">IO</a> (<a href="Foreign-ForeignPtr-Safe.html#t:ForeignPtr">ForeignPtr</a> a)</p><div class="doc"><p>This function is similar to <code><a href="Foreign-Marshal-Array.html#v:mallocArray0">mallocArray0</a></code>,
 but yields a memory area that has a finalizer attached that releases
 the memory area.  As with <code><a href="Foreign-ForeignPtr-Safe.html#v:mallocForeignPtr">mallocForeignPtr</a></code>, it is not guaranteed that
 the block of memory was allocated by <code><a href="Foreign-Marshal-Alloc.html#v:malloc">malloc</a></code>.
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>