Fix memory leak in Haskell binding and simpily example (#86)

This commit is contained in:
Ziyao
2024-03-18 21:46:51 +08:00
committed by GitHub
parent 4a69266256
commit 9981a9d1e4
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
module Ruapu where
import Foreign
import Foreign.C.String (CString, newCAString, peekCAString)
import Foreign.C.String (CString, withCAString, peekCAString)
foreign import ccall "ruapu.c ruapu_init"
init :: IO ()
@@ -15,7 +15,7 @@ foreign import ccall "ruapu.c ruapu_rua"
cRua :: IO (Ptr CString)
supports :: String -> IO Bool
supports xs = (newCAString xs) >>= cSupports
supports = flip withCAString cSupports
rua :: IO [String]
rua = cRua >>= peekArray0 nullPtr >>= mapM peekCAString