From 64fbb330dc762fde930c83bc561deea9a64c7fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 5 Aug 2001 21:23:03 +0000 Subject: Patch #448194: Debuging negative reference counts. --- Include/object.h | 11 ++++++----- 1 file 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 -- cgit v0.12