[pypy-svn] r72435 - pypy/trunk/pypy/module/cpyext

xoraxax at codespeak.net xoraxax at codespeak.net
Sat Mar 20 06:41:49 CET 2010


Author: xoraxax
Date: Sat Mar 20 06:41:48 2010
New Revision: 72435

Modified:
   pypy/trunk/pypy/module/cpyext/macros.py
Log:
Add deallocation code.

Modified: pypy/trunk/pypy/module/cpyext/macros.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/macros.py	(original)
+++ pypy/trunk/pypy/module/cpyext/macros.py	Sat Mar 20 06:41:48 2010
@@ -10,6 +10,13 @@
     state = space.fromcache(State)
     obj = state.py_objects_w2r.get(w_obj)
     obj.c_refcnt -= 1
+    if obj.c_refcnt == 0:
+        del state.py_objects_w2r[w_obj]
+        ptr = ctypes.addressof(obj._obj._storage)
+        del state.py_objects_r2w[ptr]
+        lltype.free(obj)
+    else:
+        assert obj.c_refcnt > 0
     return
 
 @cpython_api([PyObject], lltype.Void)



More information about the Pypy-commit mailing list