From: ross Date: Wed, 25 Sep 2002 22:49:17 +0000 (+0000) Subject: [project @ 2002-09-25 22:49:17 by ross] X-Git-Tag: nhc98-1-18-release~841 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=caac6315eca89a77d779fcf9d14191ece09ce982;p=haskell-directory.git [project @ 2002-09-25 22:49:17 by ross] Hugs only (but being considered for the ffi spec): added finalizerFree, a pointer to a foreign function equivalent to free, for use as a finalizer. --- diff --git a/Foreign/Marshal/Alloc.hs b/Foreign/Marshal/Alloc.hs index 25e5b78..ce167b5 100644 --- a/Foreign/Marshal/Alloc.hs +++ b/Foreign/Marshal/Alloc.hs @@ -24,11 +24,16 @@ module Foreign.Marshal.Alloc ( realloc, -- :: Storable b => Ptr a -> IO (Ptr b) reallocBytes, -- :: Ptr a -> Int -> IO (Ptr a) +#ifdef __HUGS__ + free, -- :: Ptr a -> IO () + finalizerFree -- :: FunPtr (Ptr a -> IO ()) +#else free -- :: Ptr a -> IO () +#endif ) where import Data.Maybe -import Foreign.Ptr ( Ptr, nullPtr ) +import Foreign.Ptr ( Ptr, nullPtr, FunPtr ) import Foreign.C.TypesISO ( CSize ) import Foreign.Storable ( Storable(sizeOf) ) @@ -145,3 +150,9 @@ failWhenNULL name f = do foreign import ccall unsafe "stdlib.h malloc" _malloc :: CSize -> IO (Ptr a) foreign import ccall unsafe "stdlib.h realloc" _realloc :: Ptr a -> CSize -> IO (Ptr b) foreign import ccall unsafe "stdlib.h free" _free :: Ptr a -> IO () +#ifdef __HUGS__ +-- |A pointer to a foreign function equivalent to @free@, which may be used +-- as a finalizer for storage allocated with @malloc@ or @mallocBytes@. +foreign import ccall unsafe "stdlib.h &free" + finalizerFree :: FunPtr (Ptr a -> IO ()) +#endif