From f715e053b9d3ab80fdb5cdd71ae972e07b145501 Mon Sep 17 00:00:00 2001 From: "jordi.saludes" Date: Fri, 16 Jul 2010 13:17:49 +0000 Subject: Freeing StablePtr's in PyGF. --- contrib/py-bindings/PyGF.hsc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'contrib/py-bindings/PyGF.hsc') diff --git a/contrib/py-bindings/PyGF.hsc b/contrib/py-bindings/PyGF.hsc index 7292277dd..2b44e96c9 100644 --- a/contrib/py-bindings/PyGF.hsc +++ b/contrib/py-bindings/PyGF.hsc @@ -9,6 +9,11 @@ import Foreign.C.Types #include "pygf.h" -- type PyPtr = Ptr Py +freeSp :: String -> Ptr a -> IO () +freeSp tname p = do + sp <- (#peek PyGF, sp) p + freeStablePtr sp + putStrLn $ "freeing " ++ tname ++ " at " ++ (show p) instance Storable PGF where sizeOf _ = (#size PyGF) @@ -49,7 +54,14 @@ instance Storable Tree where peek p = do sp <- (#peek PyGF, sp) p deRefStablePtr sp - + +foreign export ccall gf_freePGF :: Ptr PGF -> IO () +foreign export ccall gf_freeType :: Ptr Type -> IO () +foreign export ccall gf_freeLanguage :: Ptr Language -> IO () +gf_freePGF = freeSp "pgf" +gf_freeType = freeSp "type" +gf_freeLanguage = freeSp "language" + {-foreign export ccall gf_printCId :: Ptr CId-> IO CString gf_printCId p = do -- cgit v1.2.3