| Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
|---|
Foreign.Marshal.Alloc.Region
Contents
Description
- data LocalPtr α r
- alloca :: (Storable α, RegionControlIO pr) => (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- allocaBytes :: RegionControlIO pr => Int -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- allocaBytesAligned :: RegionControlIO pr => Int -> Int -> (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr β
- malloc :: forall α pr s. (Storable α, RegionControlIO pr) => RegionT s pr (RegionalPtr α (RegionT s pr))
- mallocBytes :: RegionControlIO 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 duplicated to a parent region.
Instances
| AllocatedPointer LocalPtr | |
| PrivateAllocatedPointer LocalPtr | |
| Pointer LocalPtr |
alloca :: (Storable α, RegionControlIO pr) => (forall sl. LocalPtr α (LocalRegion sl s) -> RegionT (Local s) pr β) -> RegionT s pr βSource
allocaBytes :: RegionControlIO 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 :: RegionControlIO 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 α, RegionControlIO 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 :: RegionControlIO 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