| Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
|---|
Foreign.Marshal.Alloc.Region
Contents
Description
- alloca :: forall α pr β. (Storable α, MonadPeelIO pr) => (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr β
- allocaBytes :: forall α pr β. MonadPeelIO pr => Int -> (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr β
- malloc :: forall α pr s. (Storable α, MonadPeelIO pr) => RegionT s pr (RegionalPtr α (RegionT s pr))
- mallocBytes :: MonadPeelIO pr => Int -> RegionT s pr (RegionalPtr α (RegionT s pr))
Local allocation
alloca :: forall α pr β. (Storable α, MonadPeelIO pr) => (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr βSource
Convenience function which allocates sufficient memory to hold values of
type α, applies the given continuation function to the resulting regional
pointer and runs the resulting region.
This should provide a safer replacement for:
Foreign.Marshal.Alloc..
alloca
Note that: alloca =
allocaBytes $ sizeOf (undefined :: α)
allocaBytes :: forall α pr β. MonadPeelIO pr => Int -> (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr βSource
Convenience function which allocates the given number of bytes, applies the given continuation function to the resulting regional pointer and runs the resulting region.
This should provide a safer replacement for:
Foreign.Marshal.Alloc..
allocaBytes
Note that: allocaBytes size f =
runRegionT $ mallocBytes size >>= f
Dynamic allocation
malloc :: forall α pr s. (Storable α, MonadPeelIO pr) => RegionT s pr (RegionalPtr α (RegionT s pr))Source
Convenience function which allocates sufficient memory to hold values of
type α and returns a regional pointer to them.
This should provide a safer replacement for:
Foreign.Marshal.Alloc..
malloc
Note that: malloc =
mallocBytes $ sizeOf (undefined :: α)
mallocBytes :: MonadPeelIO pr => Int -> RegionT s pr (RegionalPtr α (RegionT s pr))Source
Allocates the given number of bytes and returns a regional pointer to them.
This should provide a safer replacement for:
Foreign.Marshal.Alloc..
mallocBytes
TODO: Define and export: realloc and reallocBytes.