Haskell Hierarchical Libraries (base package)ContentsIndex
Foreign.Marshal.Alloc
Portability portable
Stability provisional
Maintainer ffi@haskell.org
Contents
Allocation
Description
Marshalling support: basic routines for memory allocation
Synopsis
malloc :: Storable a => IO (Ptr a)
mallocBytes :: Int -> IO (Ptr a)
alloca :: Storable a => (Ptr a -> IO b) -> IO b
allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
realloc :: Storable b => Ptr a -> IO (Ptr b)
reallocBytes :: Ptr a -> Int -> IO (Ptr a)
free :: Ptr a -> IO ()
finalizerFree :: FinalizerPtr a
Allocation
malloc :: Storable a => IO (Ptr a)
Allocate space for storable type. The size of the area allocated is determined by the sizeOf method from the instance of Storable for the appropriate type.
mallocBytes :: Int -> IO (Ptr a)
Allocate given number of bytes of storage, equivalent to C's malloc().
alloca :: Storable a => (Ptr a -> IO b) -> IO b

Temporarily allocate space for a storable type.

  • the pointer passed as an argument to the function must not escape from this function; in other words, in alloca f the allocated storage must not be used after f returns
allocaBytes :: Int -> (Ptr a -> IO b) -> IO b

Temporarily allocate the given number of bytes of storage.

  • the pointer passed as an argument to the function must not escape from this function; in other words, in allocaBytes n f the allocated storage must not be used after f returns
realloc :: Storable b => Ptr a -> IO (Ptr b)
Adjust a malloc'ed storage area to the given size of the required type (corresponds to C's realloc()).
reallocBytes :: Ptr a -> Int -> IO (Ptr a)
Adjust a malloc'ed storage area to the given size (equivalent to C's realloc()).
free :: Ptr a -> IO ()
Free malloc'ed storage (equivalent to C's free())
finalizerFree :: FinalizerPtr a
A pointer to a foreign function equivalent to free, which may be used as a finalizer for storage allocated with malloc or mallocBytes.
Produced by Haddock version 0.6