mallocForeignPtr

mallocForeignPtr :: Storable a => IO (ForeignPtr a)
base Foreign.ForeignPtr
Allocate some memory and return a ForeignPtr to it. The memory will be released automatically when the ForeignPtr is discarded. mallocForeignPtr is equivalent to > do { p <- malloc; newForeignPtr finalizerFree p } although it may be implemented differently internally: you may not assume that the memory returned by mallocForeignPtr has been allocated with Foreign.Marshal.Alloc.malloc. GHC notes: mallocForeignPtr has a heavily optimised implementation in GHC. It uses pinned memory in the garbage collected heap, so the ForeignPtr does not require a finalizer to free the memory. Use of mallocForeignPtr and associated functions is strongly recommended in preference to newForeignPtr with a finalizer.
mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a)
base Foreign.ForeignPtr
This function is similar to Foreign.Marshal.Array.mallocArray, but yields a memory area that has a finalizer attached that releases the memory area. As with mallocForeignPtr, it is not guaranteed that the block of memory was allocated by Foreign.Marshal.Alloc.malloc.
mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a)
base Foreign.ForeignPtr
This function is similar to Foreign.Marshal.Array.mallocArray0, but yields a memory area that has a finalizer attached that releases the memory area. As with mallocForeignPtr, it is not guaranteed that the block of memory was allocated by Foreign.Marshal.Alloc.malloc.
mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)
base Foreign.ForeignPtr
This function is similar to mallocForeignPtr, except that the size of the memory required is given explicitly as a number of bytes.