From 226b50628defd1795cca5b5b476aba55dccfb227 Mon Sep 17 00:00:00 2001 From: sof Date: Mon, 12 Apr 1999 18:32:17 +0000 Subject: [PATCH] [project @ 1999-04-12 18:32:17 by sof] Added Haskell wrapper for freeHaskellFunctionPtr() --- ghc/lib/exts/IOExts.lhs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ghc/lib/exts/IOExts.lhs b/ghc/lib/exts/IOExts.lhs index 1b65497..04f539d 100644 --- a/ghc/lib/exts/IOExts.lhs +++ b/ghc/lib/exts/IOExts.lhs @@ -52,6 +52,8 @@ module IOExts #endif , unsafePtrEq + + , freeHaskellFunctionPtr ) where @@ -73,6 +75,7 @@ import PrelGHC import PrelHandle import PrelErr import IO ( hPutStr, hPutChar ) +import PrelAddr ( Addr ) #endif import Ix @@ -184,3 +187,18 @@ performGC = _ccall_GC_ performGC #endif \end{code} +When using 'foreign export dynamic' to dress up a Haskell +IO action to look like a C function pointer, a little bit +of memory is allocated (along with a stable pointer to +the Haskell IO action). When done with the C function +pointer, you'll need to call @freeHaskellFunctionPtr()@ to +let go of these resources - here's the Haskell wrapper for +that RTS entry point, should you want to free it from +within Haskell. + +\begin{code} +foreign import ccall "freeHaskellFunctionPtr" + freeHaskellFunctionPtr :: Addr -> IO () + +\end{code} + -- 1.7.10.4