regional-pointers-0.1.0.1: Regional memory pointersSource codeContentsIndex
Foreign.Marshal.Alloc.Region
MaintainerBas van Dijk <v.dijk.bas@gmail.com>
Contents
Local allocation
Dynamic allocation
Description
Synopsis
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 = with . Memory

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

Convenience function which allocates the given number of bytes and returns a regional pointer to them.

This should provide a safer replacement for: Foreign.Marshal.Alloc.mallocBytes.

Note that: mallocBytes = open . Memory

TODO: Define and export: realloc and reallocBytes.
Produced by Haddock version 2.6.0