summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2009-04-07 13:24:27 (GMT)
committerMatthias Klose <doko@ubuntu.com>2009-04-07 13:24:27 (GMT)
commit091c7b16ffb2e906e41dbcb7316958ef08eabb16 (patch)
tree80b2d06a50377fa8bb417853f874e845d0ab4d4c /Include/object.h
parenta3d29e86611cccb67e59a6f75bb2163f40e4e19e (diff)
downloadcpython-091c7b16ffb2e906e41dbcb7316958ef08eabb16.zip
cpython-091c7b16ffb2e906e41dbcb7316958ef08eabb16.tar.gz
cpython-091c7b16ffb2e906e41dbcb7316958ef08eabb16.tar.bz2
Merged revisions 71229,71271 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r71229 | matthias.klose | 2009-04-05 14:43:08 +0200 (So, 05 Apr 2009) | 3 lines - Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings. (avoiding brown paper typo this time) ........ r71271 | matthias.klose | 2009-04-05 23:19:13 +0200 (So, 05 Apr 2009) | 3 lines Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)' to avoid compiler warnings. ........
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/Include/object.h b/Include/object.h
index c71bca6..d79b6ab 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -651,11 +651,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
((PyObject*)(op))->ob_refcnt++)
#define Py_DECREF(op) \
- if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
- --((PyObject*)(op))->ob_refcnt != 0) \
- _Py_CHECK_REFCNT(op) \
- else \
- _Py_Dealloc((PyObject *)(op))
+ do { \
+ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
+ --((PyObject*)(op))->ob_refcnt != 0) \
+ _Py_CHECK_REFCNT(op) \
+ else \
+ _Py_Dealloc((PyObject *)(op)); \
+ } while (0)
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
* and tp_dealloc implementatons.
@@ -701,8 +703,8 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
} while (0)
/* Macros to use in case the object pointer may be NULL: */
-#define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
-#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
+#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
+#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
/*
These are provided as conveniences to Python runtime embedders, so that