Commit 091c7b16 authored by Matthias Klose's avatar Matthias Klose

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.
........
parent a3d29e86
...@@ -651,11 +651,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); ...@@ -651,11 +651,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
((PyObject*)(op))->ob_refcnt++) ((PyObject*)(op))->ob_refcnt++)
#define Py_DECREF(op) \ #define Py_DECREF(op) \
if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ do { \
--((PyObject*)(op))->ob_refcnt != 0) \ if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
_Py_CHECK_REFCNT(op) \ --((PyObject*)(op))->ob_refcnt != 0) \
else \ _Py_CHECK_REFCNT(op) \
_Py_Dealloc((PyObject *)(op)) else \
_Py_Dealloc((PyObject *)(op)); \
} while (0)
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear /* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
* and tp_dealloc implementatons. * and tp_dealloc implementatons.
...@@ -701,8 +703,8 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); ...@@ -701,8 +703,8 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
} while (0) } while (0)
/* Macros to use in case the object pointer may be NULL: */ /* Macros to use in case the object pointer may be NULL: */
#define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op) #define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op) #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 These are provided as conveniences to Python runtime embedders, so that
......
...@@ -12,6 +12,9 @@ What's New in Python 3.1 beta 1? ...@@ -12,6 +12,9 @@ What's New in Python 3.1 beta 1?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF: Add `do { ... } while (0)'
to avoid compiler warnings.
Library Library
------- -------
...@@ -78,8 +81,6 @@ Core and Builtins ...@@ -78,8 +81,6 @@ Core and Builtins
- Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with - Issue #3845: In PyRun_SimpleFileExFlags avoid invalid memory access with
short file names. short file names.
- Py_DECREF: Add `do { ... } while (0)' to avoid compiler warnings.
Library Library
------- -------
......
...@@ -693,13 +693,13 @@ on_completion_display_matches_hook(char **matches, ...@@ -693,13 +693,13 @@ on_completion_display_matches_hook(char **matches,
r = PyObject_CallFunction(completion_display_matches_hook, r = PyObject_CallFunction(completion_display_matches_hook,
"sOi", matches[0], m, max_length); "sOi", matches[0], m, max_length);
Py_DECREF(m), m=NULL; Py_DECREF(m); m=NULL;
if (r == NULL || if (r == NULL ||
(r != Py_None && PyLong_AsLong(r) == -1 && PyErr_Occurred())) { (r != Py_None && PyLong_AsLong(r) == -1 && PyErr_Occurred())) {
goto error; goto error;
} }
Py_XDECREF(r), r=NULL; Py_XDECREF(r); r=NULL;
if (0) { if (0) {
error: error:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment