allocaBytes +base

allocaBytes :: Int -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Alloc
allocaBytes n f executes the computation f, passing as argument a pointer to a temporarily allocated block of memory of n 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 is freed when f terminates (either normally or via an exception), so the pointer passed to f must not be used after this.
allocaBytesAligned :: Int -> Int -> (Ptr a -> IO b) -> IO b
base Foreign.Marshal.Alloc