Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Synopsis
- 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)
- thawInplace :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a)
- freeze :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)
- freezeInplace :: Storable a => Int -> MutablePtr a -> IO (ForeignPtr a)
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.
mutable arrays
data MutablePtr a Source #
withMutablePtr :: MutablePtr a -> (Ptr a -> IO b) -> IO b Source #
thaw :: Storable a => Int -> ForeignPtr a -> IO (MutablePtr a) 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.