malloc

malloc :: Storable a => IO (Ptr a)
base Foreign.Marshal.Alloc
Allocate a block of memory that is sufficient to hold values of type a. The size of the area allocated is determined by the sizeOf method from the instance of Storable for the appropriate type. The memory may be deallocated using free or finalizerFree when no longer required.
mallocArray :: Storable a => Int -> IO (Ptr a)
base Foreign.Marshal.Array
Allocate storage for the given number of elements of a storable type (like Foreign.Marshal.Alloc.malloc, but for multiple elements).
mallocArray0 :: Storable a => Int -> IO (Ptr a)
base Foreign.Marshal.Array
Like mallocArray, but add an extra position to hold a special termination element.
mallocBytes :: Int -> IO (Ptr a)
base Foreign.Marshal.Alloc
Allocate a block of memory of the given number of bytes. The block of memory is sufficiently aligned for any of the basic foreign types that fits into a memory block of the allocated size. The memory may be deallocated using free or finalizerFree when no longer required.
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.
pooledMalloc :: Storable a => Pool -> IO (Ptr a)
base Foreign.Marshal.Pool
Allocate space for storable type in the given pool. The size of the area allocated is determined by the sizeOf method from the instance of Storable for the appropriate type.
pooledMallocArray :: Storable a => Pool -> Int -> IO (Ptr a)
base Foreign.Marshal.Pool
Allocate storage for the given number of elements of a storable type in the pool.
pooledMallocArray0 :: Storable a => Pool -> Int -> IO (Ptr a)
base Foreign.Marshal.Pool
Allocate storage for the given number of elements of a storable type in the pool, but leave room for an extra element to signal the end of the array.
pooledMallocBytes :: Pool -> Int -> IO (Ptr a)
base Foreign.Marshal.Pool
Allocate the given number of bytes of storage in the pool.
unsafePackMallocCString :: CString -> IO ByteString
bytestring Data.ByteString.Unsafe
O(n) Build a ByteString from a malloced CString. This value will have a free(3) finalizer associated to it. This funtion is unsafe. If the original CString is later modified, this change will be reflected in the resulting ByteString, breaking referential transparency. This function is also unsafe if you call its finalizer twice, which will result in a double free error, or if you pass it a CString not allocated with malloc.
unsafePackMallocCStringLen :: CStringLen -> IO ByteString
bytestring Data.ByteString.Unsafe
O(n) Build a ByteString from a malloced CStringLen. This value will have a free(3) finalizer associated to it. This funtion is unsafe. If the original CString is later modified, this change will be reflected in the resulting ByteString, breaking referential transparency. This function is also unsafe if you call its finalizer twice, which will result in a double free error, or if you pass it a CString not allocated with malloc.