From: ross Date: Wed, 22 Jan 2003 10:55:56 +0000 (+0000) Subject: [project @ 2003-01-22 10:55:56 by ross] X-Git-Tag: nhc98-1-18-release~757 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=dc973410f9f28e34f3df1bbe76cee9592204c95b;p=haskell-directory.git [project @ 2003-01-22 10:55:56 by ross] add mallocForeignPtrArray and mallocForeignPtrArray0 as per latest FFI draft. --- 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