summaryrefslogtreecommitdiff
path: root/contrib/py-bindings/PyGF.hsc
diff options
context:
space:
mode:
authorjordi.saludes <jordi.saludes@upc.edu>2010-07-16 13:17:49 +0000
committerjordi.saludes <jordi.saludes@upc.edu>2010-07-16 13:17:49 +0000
commitf715e053b9d3ab80fdb5cdd71ae972e07b145501 (patch)
tree476149f52c76979a757a0c49cd93c547713c3ff1 /contrib/py-bindings/PyGF.hsc
parent5b14dd8da59f2da305004ef7b9ab28b21b8f4df8 (diff)
Freeing StablePtr's in PyGF.
Diffstat (limited to 'contrib/py-bindings/PyGF.hsc')
-rw-r--r--contrib/py-bindings/PyGF.hsc14
1 files changed, 13 insertions, 1 deletions
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