X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Foreign%2FMarshal%2FAlloc.hs;h=fb9f8dd351e5b2144757687305036aac50b729d8;hb=e689c74ff37943db15ce9886f6361387a8f80e5f;hp=65294cefea71b469d8e45e37640bdeb65c14258f;hpb=7196f1ea1790dc0ef7986ae6757bdcf46a286e3f;p=ghc-base.git diff --git a/Foreign/Marshal/Alloc.hs b/Foreign/Marshal/Alloc.hs index 65294ce..fb9f8dd 100644 --- a/Foreign/Marshal/Alloc.hs +++ b/Foreign/Marshal/Alloc.hs @@ -30,22 +30,28 @@ module Foreign.Marshal.Alloc ( import Data.Maybe import Foreign.Ptr ( Ptr, nullPtr, FunPtr ) -import Foreign.ForeignPtr ( FinalizerPtr ) import Foreign.C.Types ( CSize ) import Foreign.Storable ( Storable(sizeOf) ) #ifdef __GLASGOW_HASKELL__ +import Foreign.ForeignPtr ( FinalizerPtr ) import GHC.IOBase import GHC.Real import GHC.Ptr import GHC.Err import GHC.Base +import GHC.Num #elif defined(__NHC__) +import NHC.FFI ( FinalizerPtr, CInt(..) ) import IO ( bracket ) #else import Control.Exception ( bracket ) #endif +#ifdef __HUGS__ +import Hugs.ForeignPtr ( FinalizerPtr ) +#endif + -- exported functions -- ------------------ @@ -115,6 +121,7 @@ realloc = doRealloc undefined -- C\'s @realloc()@). -- reallocBytes :: Ptr a -> Int -> IO (Ptr a) +reallocBytes ptr 0 = do free ptr; return nullPtr reallocBytes ptr size = failWhenNULL "realloc" (_realloc ptr (fromIntegral size))