untabify
[ghc-base.git] / Foreign / Marshal / Alloc.hs
index 65588ff..b7cd225 100644 (file)
@@ -1,4 +1,4 @@
-{-# OPTIONS -fno-implicit-prelude #-}
+{-# OPTIONS_GHC -fno-implicit-prelude #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Foreign.Marshal.Alloc
@@ -24,19 +24,19 @@ module Foreign.Marshal.Alloc (
   mallocBytes,  -- ::               Int -> IO (Ptr a)
 
   realloc,      -- :: Storable b => Ptr a        -> IO (Ptr b)
-  reallocBytes, -- ::              Ptr a -> Int -> IO (Ptr a)
+  reallocBytes, -- ::               Ptr a -> Int -> IO (Ptr a)
 
   free,         -- :: Ptr a -> IO ()
   finalizerFree -- :: FinalizerPtr a
 ) where
 
 import Data.Maybe
-import Foreign.Ptr             ( Ptr, nullPtr, FunPtr )
-import Foreign.C.Types         ( CSize )
-import Foreign.Storable        ( Storable(sizeOf) )
+import Foreign.Ptr              ( Ptr, nullPtr, FunPtr )
+import Foreign.C.Types          ( CSize )
+import Foreign.Storable         ( Storable(sizeOf) )
 
 #ifdef __GLASGOW_HASKELL__
-import Foreign.ForeignPtr      ( FinalizerPtr )
+import Foreign.ForeignPtr       ( FinalizerPtr )
 import GHC.IOBase
 import GHC.Real
 import GHC.Ptr
@@ -44,14 +44,16 @@ import GHC.Err
 import GHC.Base
 import GHC.Num
 #elif defined(__NHC__)
-import NHC.FFI                 ( FinalizerPtr, CInt(..) )
-import IO                      ( bracket )
+import NHC.FFI                  ( FinalizerPtr, CInt(..) )
+import IO                       ( bracket )
 #else
-import Control.Exception       ( bracket )
+import Control.Exception        ( bracket )
 #endif
 
 #ifdef __HUGS__
-import Hugs.ForeignPtr         ( FinalizerPtr )
+import Hugs.Prelude             ( IOException(IOError),
+                                  IOErrorType(ResourceExhausted) )
+import Hugs.ForeignPtr          ( FinalizerPtr )
 #endif
 
 
@@ -133,9 +135,9 @@ realloc  = doRealloc undefined
   where
     doRealloc           :: Storable b' => b' -> Ptr a' -> IO (Ptr b')
     doRealloc dummy ptr  = let
-                            size = fromIntegral (sizeOf dummy)
-                          in
-                          failWhenNULL "realloc" (_realloc ptr size)
+                             size = fromIntegral (sizeOf dummy)
+                           in
+                           failWhenNULL "realloc" (_realloc ptr size)
 
 -- |Resize a memory area that was allocated with 'malloc' or 'mallocBytes'
 -- to the given size.  The returned pointer may refer to an entirely
@@ -173,9 +175,9 @@ failWhenNULL :: String -> IO (Ptr a) -> IO (Ptr a)
 failWhenNULL name f = do
    addr <- f
    if addr == nullPtr
-#ifdef __GLASGOW_HASKELL__
-      then ioException (IOError Nothing ResourceExhausted name 
-                                       "out of memory" Nothing)
+#if __GLASGOW_HASKELL__ || __HUGS__
+      then ioError (IOError Nothing ResourceExhausted name 
+                                        "out of memory" Nothing)
 #else
       then ioError (userError (name++": out of memory"))
 #endif