mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Be more careful with negative reference counts.
This commit is contained in:
parent
3d54f2d3d9
commit
c8564cde04
1 changed files with 3 additions and 3 deletions
|
@ -56,7 +56,7 @@ whose size is determined when the object is allocated.
|
||||||
#ifdef TRACE_REFS
|
#ifdef TRACE_REFS
|
||||||
#define OB_HEAD \
|
#define OB_HEAD \
|
||||||
struct _object *_ob_next, *_ob_prev; \
|
struct _object *_ob_next, *_ob_prev; \
|
||||||
unsigned int ob_refcnt; \
|
int ob_refcnt; \
|
||||||
struct _typeobject *ob_type;
|
struct _typeobject *ob_type;
|
||||||
#define OB_HEAD_INIT(type) 0, 0, 1, type,
|
#define OB_HEAD_INIT(type) 0, 0, 1, type,
|
||||||
#else
|
#else
|
||||||
|
@ -200,7 +200,7 @@ extern long ref_total;
|
||||||
#endif
|
#endif
|
||||||
#define INCREF(op) (ref_total++, (op)->ob_refcnt++)
|
#define INCREF(op) (ref_total++, (op)->ob_refcnt++)
|
||||||
#define DECREF(op) \
|
#define DECREF(op) \
|
||||||
if (--ref_total, --(op)->ob_refcnt != 0) \
|
if (--ref_total, --(op)->ob_refcnt > 0) \
|
||||||
; \
|
; \
|
||||||
else \
|
else \
|
||||||
DELREF(op)
|
DELREF(op)
|
||||||
|
@ -208,7 +208,7 @@ extern long ref_total;
|
||||||
#define NEWREF(op) ((op)->ob_refcnt = 1)
|
#define NEWREF(op) ((op)->ob_refcnt = 1)
|
||||||
#define INCREF(op) ((op)->ob_refcnt++)
|
#define INCREF(op) ((op)->ob_refcnt++)
|
||||||
#define DECREF(op) \
|
#define DECREF(op) \
|
||||||
if (--(op)->ob_refcnt != 0) \
|
if (--(op)->ob_refcnt > 0) \
|
||||||
; \
|
; \
|
||||||
else \
|
else \
|
||||||
DELREF(op)
|
DELREF(op)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue