[project @ 2002-09-25 22:49:17 by ross]
authorross <unknown>
Wed, 25 Sep 2002 22:49:17 +0000 (22:49 +0000)
committerross <unknown>
Wed, 25 Sep 2002 22:49:17 +0000 (22:49 +0000)
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.

Foreign/Marshal/Alloc.hs

index 25e5b78..ce167b5 100644 (file)
@@ -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