diff options
author | Andrew Martin <andrew.thaddeus@gmail.com> | 2020-05-24 08:52:05 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-04 04:36:03 -0400 |
commit | 1b975aedb1b74b8694d14ba8fdc5955497f8f31c (patch) | |
tree | 2b940496ce6b4bd1a6fff04b492c7386e4495082 /libraries | |
parent | c05756cdef800f1d8e92114222bcc480bce758b9 (diff) | |
download | haskell-1b975aedb1b74b8694d14ba8fdc5955497f8f31c.tar.gz |
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.
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/ForeignPtr.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libraries/base/GHC/ForeignPtr.hs b/libraries/base/GHC/ForeignPtr.hs index 9ba6a2b017..27e83f453f 100644 --- a/libraries/base/GHC/ForeignPtr.hs +++ b/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 |