-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Memory allocation with added stress tests and integrity checks
--   
--   Provide adaptions of <tt>mallocForeignPtrArray</tt> and
--   <tt>allocaArray</tt> that add stress tests and integrity checks.
--   
--   There are three modules:
--   
--   <ul>
--   <li><tt>Guarded.Plain</tt>: exports the original allocation
--   routines</li>
--   <li><tt>Guarded.Debug</tt>: exports allocation routines that add
--   stress and checks</li>
--   <li><tt>Guarded</tt>: exports either <tt>Guarded.Plain</tt> or
--   <tt>Guarded.Debug</tt> depending on the Cabal <tt>debug</tt>
--   flag.</li>
--   </ul>
--   
--   It is intended that you always import the <tt>Guarded</tt> module in
--   user code and install a package version with enabled debug flag to a
--   custom package database for debugging. If you compile your user
--   program you can choose production or debugging mode by choosing the
--   default or the custom debugging package database, respectively.
--   
--   This package is inspired by the famous Amiga debug tool MungWall. The
--   Linux counterpart is Electric Fence.
@package guarded-allocation
@version 0.0.1

module Foreign.Marshal.Array.Guarded.Plain
create :: Storable a => Int -> (Ptr a -> IO b) -> IO (ForeignPtr a, b)
alloca :: Storable a => Int -> (Ptr a -> IO b) -> IO b
data MutablePtr a
new :: Storable a => Int -> IO (MutablePtr a)
withMutablePtr :: MutablePtr a -> (Ptr a -> IO b) -> IO b

-- | The <tt>size</tt> parameter must match the size passed to <a>new</a>.
--   This is not checked.
freeze :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)

-- | <a>freezeInplace</a> must be the last operation on the
--   <a>MutablePtr</a> and its associated array. This is not checked.
freezeInplace :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)
thaw :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)
thawInplace :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)

module Foreign.Marshal.Array.Guarded.Debug

-- | Array creation with additional immutability check, electrical fence
--   and pollution of uncleaned memory.
--   
--   The function checks that the array is not altered anymore after
--   creation.
create :: Storable a => Int -> (Ptr a -> IO b) -> IO (ForeignPtr a, b)
alloca :: Storable a => Int -> (Ptr a -> IO b) -> IO b
data MutablePtr a
new :: Storable a => Int -> IO (MutablePtr a)
withMutablePtr :: MutablePtr a -> (Ptr a -> IO b) -> IO b
thaw :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)

-- | There is not much we can debug here. We cannot add a fence since we do
--   not copy the immutable array. We could debug more if we would
--   implement <a>thawInplace</a> as a redirection to <a>thaw</a>.
thawInplace :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)

-- | The <tt>size</tt> parameter must match the size passed to <a>new</a>.
--   This is checked.
freeze :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)

-- | <a>freezeInplace</a> must be the last operation on the
--   <a>MutablePtr</a> and its associated array. The <tt>size</tt>
--   parameter must match the size passed to <a>new</a>. This is checked.
--   
--   It may fail if the <a>MutablePtr</a> was constructed using
--   <a>thawInplace</a> from a <a>ForeignPtr</a> with a C finalizer.
freezeInplace :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)

module Foreign.Marshal.Array.Guarded
create :: Storable a => Int -> (Ptr a -> IO b) -> IO (ForeignPtr a, b)
alloca :: Storable a => Int -> (Ptr a -> IO b) -> IO b
data MutablePtr a
new :: Storable a => Int -> IO (MutablePtr a)
withMutablePtr :: MutablePtr a -> (Ptr a -> IO b) -> IO b

-- | The <tt>size</tt> parameter must match the size passed to <a>new</a>.
--   This is not checked.
freeze :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)

-- | <a>freezeInplace</a> must be the last operation on the
--   <a>MutablePtr</a> and its associated array. This is not checked.
freezeInplace :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)
thaw :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)
thawInplace :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)
