[Git][ghc/ghc][master] Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr.
Marge Bot
gitlab at gitlab.haskell.org
Thu Jun 4 08:36:13 UTC 2020
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
1b975aed by Andrew Martin at 2020-06-04T04:36:03-04:00
Allow finalizeForeignPtr to be called on FinalPtr/PlainPtr.
MR 2165 (commit 49301ad6226d9a83d110bee8c419615dd94f5ded) regressed
finalizeForeignPtr by throwing exceptions when PlainPtr was encounterd.
This regression did not make it into a release of GHC. Here, the
original behavior is restored, and FinalPtr is given the same treatment
as PlainPtr.
- - - - -
1 changed file:
- libraries/base/GHC/ForeignPtr.hs
Changes:
=====================================
libraries/base/GHC/ForeignPtr.hs
=====================================
@@ -572,12 +572,14 @@ plusForeignPtr (ForeignPtr addr c) (I# d) = ForeignPtr (plusAddr# addr d) c
-- | Causes the finalizers associated with a foreign pointer to be run
-- immediately. The foreign pointer must not be used again after this
--- function is called.
+-- function is called. If the foreign pointer does not support finalizers,
+-- this is a no-op.
finalizeForeignPtr :: ForeignPtr a -> IO ()
finalizeForeignPtr (ForeignPtr _ c) = case c of
PlainForeignPtr ref -> foreignPtrFinalizer ref
MallocPtr _ ref -> foreignPtrFinalizer ref
- _ -> errorWithoutStackTrace "finalizeForeignPtr PlainPtr"
+ PlainPtr{} -> return ()
+ FinalPtr{} -> return ()
{- $commentary
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b975aedb1b74b8694d14ba8fdc5955497f8f31c
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/1b975aedb1b74b8694d14ba8fdc5955497f8f31c
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200604/2be5d010/attachment.html>
More information about the ghc-commits
mailing list