guarded-allocation-0.0.1: Memory allocation with added stress tests and integrity checks

Foreign.Marshal.Array.Guarded.Debug

Contents

Synopsis

# immutable arrays

create :: Storable a => Int -> (Ptr a -> IO b) -> IO (ForeignPtr a, b) Source #

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.

alloca :: Storable a => Int -> (Ptr a -> IO b) -> IO b Source #

# mutable arrays

withMutablePtr :: MutablePtr a -> (Ptr a -> IO b) -> IO b Source #

thawInplace :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a) Source #

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 thawInplace as a redirection to thaw.

freeze :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a) Source #

The size parameter must match the size passed to new. This is checked.

freezeInplace :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a) Source #

freezeInplace must be the last operation on the MutablePtr and its associated array. The size parameter must match the size passed to new. This is checked.

It may fail if the MutablePtr was constructed using thawInplace from a ForeignPtr with a C finalizer.