inline-c 0.5.3.0 → 0.5.3.1
raw patch · 3 files changed
+9/−3 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +1/−0
- inline-c.cabal +1/−1
- src/Language/C/Inline/Context.hs +7/−2
changelog.md view
@@ -1,3 +1,4 @@+- 0.5.3.1: Fix leak of `FunPtr` when using `funCtx`. - 0.5.3.0: Recognize more standard library types. See pull request #19. - 0.5.2.1: Convert `signed char` to `CSChar`. See pull request #18. - 0.5.2.0: Make `bs-ptr` use `char` instead of `unsigned char`. See
inline-c.cabal view
@@ -1,5 +1,5 @@ name: inline-c-version: 0.5.3.0+version: 0.5.3.1 synopsis: Write Haskell source files including C code inline. No FFI required. description: See <https://github.com/fpco/inline-c/blob/master/README.md>. license: MIT
src/Language/C/Inline/Context.hs view
@@ -55,7 +55,7 @@ import qualified Data.Vector.Storable.Mutable as VM import Data.Word (Word8, Word16, Word32, Word64) import Foreign.C.Types-import Foreign.Ptr (Ptr, FunPtr)+import Foreign.Ptr (Ptr, FunPtr, freeHaskellFunPtr) import Foreign.Storable (Storable) import qualified Language.Haskell.TH as TH import qualified Text.Parser.Token as Parser@@ -314,7 +314,12 @@ hsExp <- getHsVariable "funCtx" cId case hsTy of TH.AppT (TH.ConT n) hsTy' | n == ''FunPtr -> do- hsExp' <- [| \cont -> cont =<< $(mkFunPtr (return hsTy')) $(return hsExp) |]+ hsExp' <- [| \cont -> do+ funPtr <- $(mkFunPtr (return hsTy')) $(return hsExp)+ x <- cont funPtr+ freeHaskellFunPtr funPtr+ return x+ |] return (hsTy, hsExp') _ -> error "The `fun' marshaller captures function pointers only" }