Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
---|
- alloca :: forall α pr β. (Storable α, MonadCatchIO pr) => (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr β
- allocaBytes :: forall α pr β. MonadCatchIO pr => Int -> (forall s. RegionalPtr α (RegionT s pr) -> RegionT s pr β) -> pr β
- malloc :: forall α pr s. (Storable α, MonadCatchIO pr) => RegionT s pr (RegionalPtr α (RegionT s pr))
- mallocBytes :: MonadCatchIO pr => Int -> RegionT s pr (RegionalPtr α (RegionT s pr))
Local allocation
alloca :: forall α pr β. (Storable α, MonadCatchIO 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 β. MonadCatchIO 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 α, MonadCatchIO 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 :: MonadCatchIO 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
.