[pypy-commit] pypy PyTuple_Type-subclass: fix memory leak, define and use fast path for dealloc

mattip pypy.commits at gmail.com
Fri Jun 24 02:40:09 EDT 2016


Author: Matti Picus <matti.picus at gmail.com>
Branch: PyTuple_Type-subclass
Changeset: r85364:57294d559e31
Date: 2016-06-23 22:39 +0300
http://bitbucket.org/pypy/pypy/changeset/57294d559e31/

Log:	fix memory leak, define and use fast path for dealloc

diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py
--- a/pypy/module/cpyext/object.py
+++ b/pypy/module/cpyext/object.py
@@ -54,6 +54,9 @@
 
 @cpython_api([PyObject], lltype.Void)
 def PyObject_dealloc(space, obj):
+    return _dealloc(space, obj)
+
+def _dealloc(space, obj):
     # This frees an object after its refcount dropped to zero, so we
     # assert that it is really zero here.
     assert obj.c_ob_refcnt == 0
diff --git a/pypy/module/cpyext/tupleobject.py b/pypy/module/cpyext/tupleobject.py
--- a/pypy/module/cpyext/tupleobject.py
+++ b/pypy/module/cpyext/tupleobject.py
@@ -122,8 +122,8 @@
     for i in range(py_tup.c_ob_size):
         if p[i] and p[i].c_ob_refcnt > 0:
             decref(space, p[i])
-    while py_obj.c_ob_refcnt > 0:
-        decref(space, py_obj)
+    from pypy.module.cpyext.object import _dealloc
+    _dealloc(space, py_obj)
 
 #_______________________________________________________________________
 


More information about the pypy-commit mailing list