From dc973410f9f28e34f3df1bbe76cee9592204c95b Mon Sep 17 00:00:00 2001 From: ross Date: Wed, 22 Jan 2003 10:55:56 +0000 Subject: [PATCH] [project @ 2003-01-22 10:55:56 by ross] add mallocForeignPtrArray and mallocForeignPtrArray0 as per latest FFI draft. --- Foreign/ForeignPtr.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Foreign/ForeignPtr.hs b/Foreign/ForeignPtr.hs index 3b37c6d..a1e8550 100644 --- a/Foreign/ForeignPtr.hs +++ b/Foreign/ForeignPtr.hs @@ -29,6 +29,8 @@ module Foreign.ForeignPtr #ifndef __NHC__ , mallocForeignPtr -- :: Storable a => IO (ForeignPtr a) , mallocForeignPtrBytes -- :: Int -> IO (ForeignPtr a) + , mallocForeignPtrArray -- :: Storable a => Int -> IO (ForeignPtr a) + , mallocForeignPtrArray0 -- :: Storable a => Int -> IO (ForeignPtr a) #endif ) where @@ -228,3 +230,13 @@ castForeignPtr (ForeignPtr a) = ForeignPtr a castForeignPtr (MallocPtr a) = MallocPtr a #endif +#ifndef __NHC__ +mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) +mallocForeignPtrArray = doMalloc undefined + where + doMalloc :: Storable a => a -> Int -> IO (ForeignPtr a) + doMalloc dummy size = mallocForeignPtrBytes (size * sizeOf dummy) + +mallocForeignPtrArray0 :: Storable a => Int -> IO (ForeignPtr a) +mallocForeignPtrArray0 size = mallocForeignPtrArray (size + 1) +#endif -- 1.7.10.4