Fix memory leak in Haskell binding and simpily example (#86)
This commit is contained in:
		
							parent
							
								
									4a69266256
								
							
						
					
					
						commit
						9981a9d1e4
					
				| @ -327,7 +327,7 @@ import Ruapu | ||||
| main = do | ||||
|     Ruapu.init | ||||
|     Ruapu.supports "mmx" >>= putStrLn . show | ||||
|     Ruapu.rua >>= foldl (\m x -> m >> putStrLn x) (return ()) | ||||
|     Ruapu.rua >>= sequence_ . map putStrLn | ||||
| ``` | ||||
| </td></tr> | ||||
| </table> | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user