Fix memory leak in Haskell binding and simpily example (#86)
This commit is contained in:
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user