summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-08-05 21:23:03 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-08-05 21:23:03 (GMT)
commit64fbb330dc762fde930c83bc561deea9a64c7fcf (patch)
tree6422bdd1465681485c2e866ff0659d14aae6dcc9 /Include
parent58212724f2ab5ea83ec646ee620c0f74207b24c8 (diff)
downloadcpython-64fbb330dc762fde930c83bc561deea9a64c7fcf.zip
cpython-64fbb330dc762fde930c83bc561deea9a64c7fcf.tar.gz
cpython-64fbb330dc762fde930c83bc561deea9a64c7fcf.tar.bz2
Patch #448194: Debuging negative reference counts.
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/Include/object.h b/Include/object.h
index d81d4c2..1f749ec 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -489,11 +489,12 @@ extern DL_IMPORT(long) _Py_RefTotal;
#endif /* !Py_TRACE_REFS */
#define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++)
-#define Py_DECREF(op) \
- if (--_Py_RefTotal, (--((op)->ob_refcnt) != 0)) \
- ; \
- else \
- _Py_Dealloc((PyObject *)(op))
+ /* under Py_REF_DEBUG: also log negative ref counts after Py_DECREF() !! */
+#define Py_DECREF(op) \
+ if (--_Py_RefTotal, 0 < (--((op)->ob_refcnt))) ; \
+ else if (0 == (op)->ob_refcnt) _Py_Dealloc( (PyObject*)(op)); \
+ else (void)fprintf( stderr, "%s:%i negative ref count %i\n", \
+ __FILE__, __LINE__, (op)->ob_refcnt)
#else /* !Py_REF_DEBUG */
#ifdef COUNT_ALLOCS