[project @ 2006-01-09 13:25:50 by simonmar]
[ghc-hetmet.git] / ghc / compiler / utils / Binary.hs
index 7b40bd2..cdb9206 100644 (file)
@@ -722,6 +722,16 @@ getFS bh = do
   --
   go 0
 
+#if __GLASGOW_HASKELL__ < 600
+mallocForeignPtrBytes :: Int -> IO (ForeignPtr a)
+mallocForeignPtrBytes n = do
+  r <- mallocBytes n
+  newForeignPtr r (finalizerFree r)
+
+foreign import ccall unsafe "stdlib.h free" 
+  finalizerFree :: Ptr a -> IO ()
+#endif
+
 instance Binary PackageId where
   put_ bh pid = put_ bh (packageIdFS pid)
   get bh = do { fs <- get bh; return (fsToPackageId fs) }