module Foreign.Marshal.Array.Guarded.Plain ( create, alloca, ) where import Foreign.Marshal.Array (allocaArray) import Foreign.Storable (Storable) import Foreign.ForeignPtr (ForeignPtr, withForeignPtr, mallocForeignPtrArray) import Foreign.Ptr (Ptr) import Control.Applicative ((<$>)) create :: (Storable a) => Int -> (Ptr a -> IO b) -> IO (ForeignPtr a, b) create size f = do fptr <- mallocForeignPtrArray size (,) fptr <$> withForeignPtr fptr f alloca :: (Storable a) => Int -> (Ptr a -> IO b) -> IO b alloca = allocaArray