Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|
- data LocalPtr α r
- alloca :: (Storable α, MonadControlIO pr) => (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- allocaBytes :: MonadControlIO pr => Int -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- allocaBytesAligned :: MonadControlIO pr => Int -> Int -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- malloc :: forall α pr s. (Storable α, MonadControlIO pr) => RegionT s pr (RegionalPtr α (RegionT s pr))
- mallocBytes :: MonadControlIO pr => Int -> RegionT s pr (RegionalPtr α (RegionT s pr))
Local allocation
A regional pointer to memory which was locally allocated
by one of the alloca
-like functions.
Note that a LocalPtr
can not be dup
licated to a parent region.
AllocatedPointer LocalPtr | |
PrivateAllocatedPointer LocalPtr | |
Pointer LocalPtr |
alloca :: (Storable α, MonadControlIO pr) => (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr βSource
allocaBytes :: MonadControlIO pr => Int -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr βSource
executes the computation allocaBytes
n ff
, passing as argument a
pointer to a temporarily allocated block of memory of n
bytes.
The block of memory is sufficiently aligned for any of the basic foreign types
that fits into a memory block of the allocated size.
The memory is freed when f
terminates (either normally or via an exception).
This should provide a safer replacement for:
Foreign.Marshal.Alloc.
.
allocaBytes
allocaBytesAligned :: MonadControlIO pr => Int -> Int -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr βSource
This should provide a safer replacement for:
Foreign.Marshal.Alloc.
.
allocaBytesAligned
Dynamic allocation
malloc :: forall α pr s. (Storable α, MonadControlIO pr) => RegionT s pr (RegionalPtr α (RegionT s pr))Source
Allocate a block of memory that is sufficient to hold values of type α
.
Note that: malloc =
mallocBytes
$ sizeOf
(undefined :: α)
This should provide a safer replacement for:
Foreign.Marshal.Alloc.
.
malloc
mallocBytes :: MonadControlIO pr => Int -> RegionT s pr (RegionalPtr α (RegionT s pr))Source
Allocate a block of memory of the given number of bytes. The block of memory is sufficiently aligned for any of the basic foreign types that fits into a memory block of the allocated size.
This should provide a safer replacement for:
Foreign.Marshal.Alloc.
.
mallocBytes