From bbbe42147fd9666c2c00d7097ac381a3ff437958 Mon Sep 17 00:00:00 2001 From: ross Date: Fri, 1 Aug 2003 10:00:49 +0000 Subject: [PATCH] [project @ 2003-08-01 10:00:48 by ross] Swapped argument order of `newForeignPtr' and `addForeignPtrFinalizer' to track FFI spec. (Maybe the Conc ones should do the same?) This will break NHC. --- Foreign/ForeignPtr.hs | 10 +++++----- GHC/ForeignPtr.hs | 4 ++-- Text/Regex/Posix.hsc | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Foreign/ForeignPtr.hs b/Foreign/ForeignPtr.hs index af39a61..9705181 100644 --- a/Foreign/ForeignPtr.hs +++ b/Foreign/ForeignPtr.hs @@ -88,7 +88,7 @@ instance Show (ForeignPtr a) where #ifndef __NHC__ -newForeignPtr :: Ptr a -> FinalizerPtr a -> IO (ForeignPtr a) +newForeignPtr :: FinalizerPtr a -> Ptr a -> IO (ForeignPtr a) -- ^Turns a plain memory reference into a foreign pointer, and -- associates a finaliser with the reference. The finaliser will be executed -- after the last reference to the foreign object is dropped. Note that there @@ -96,9 +96,9 @@ newForeignPtr :: Ptr a -> FinalizerPtr a -> IO (ForeignPtr a) -- reference was dropped; this depends on the details of the Haskell storage -- manager. The only guarantee is that the finaliser runs before the program -- terminates. -newForeignPtr p finalizer +newForeignPtr finalizer p = do fObj <- newForeignPtr_ p - addForeignPtrFinalizer fObj finalizer + addForeignPtrFinalizer finalizer fObj return fObj withForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b @@ -131,12 +131,12 @@ withForeignPtr fo io mallocForeignPtr :: Storable a => IO (ForeignPtr a) mallocForeignPtr = do r <- malloc - newForeignPtr r finalizerFree + newForeignPtr finalizerFree r mallocForeignPtrBytes :: Int -> IO (ForeignPtr a) mallocForeignPtrBytes n = do r <- mallocBytes n - newForeignPtr r finalizerFree + newForeignPtr finalizerFree r #endif /* __HUGS__ || __NHC__ */ mallocForeignPtrArray :: Storable a => Int -> IO (ForeignPtr a) diff --git a/GHC/ForeignPtr.hs b/GHC/ForeignPtr.hs index 1778623..3536111 100644 --- a/GHC/ForeignPtr.hs +++ b/GHC/ForeignPtr.hs @@ -127,11 +127,11 @@ mallocForeignPtrBytes (I# size) = do (# s, MallocPtr mbarr# r #) } -addForeignPtrFinalizer :: ForeignPtr a -> FinalizerPtr a -> IO () +addForeignPtrFinalizer :: FinalizerPtr a -> ForeignPtr a -> IO () -- ^This function adds a finaliser to the given foreign object. The -- finalizer will run /before/ all other finalizers for the same -- object which have already been registered. -addForeignPtrFinalizer fptr finalizer = +addForeignPtrFinalizer finalizer fptr = addForeignPtrConcFinalizer fptr (mkFinalizer finalizer (unsafeForeignPtrToPtr fptr)) diff --git a/Text/Regex/Posix.hsc b/Text/Regex/Posix.hsc index 1937884..65ab13d 100644 --- a/Text/Regex/Posix.hsc +++ b/Text/Regex/Posix.hsc @@ -61,7 +61,7 @@ regcomp pattern flags = do withForeignPtr regex_fptr $ \p -> c_regcomp p cstr (fromIntegral flags) if (r == 0) - then do addForeignPtrFinalizer regex_fptr ptr_regfree + then do addForeignPtrFinalizer ptr_regfree regex_fptr return (Regex regex_fptr) else error "Text.Regex.Posix.regcomp: error in pattern" -- ToDo -- 1.7.10.4