Commit 541497e6 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-35059: Convert Py_XINCREF() to static inline function (GH-10224)

Convert Py_XINCREF() and Py_XDECREF() macros into static inline
functions.
parent 0200928e
...@@ -871,20 +871,24 @@ static inline void _Py_DECREF(const char *filename, int lineno, ...@@ -871,20 +871,24 @@ static inline void _Py_DECREF(const char *filename, int lineno,
} \ } \
} while (0) } while (0)
/* Macros to use in case the object pointer may be NULL: */ /* Function to use in case the object pointer can be NULL: */
#define Py_XINCREF(op) \ static inline void _Py_XINCREF(PyObject *op)
do { \ {
PyObject *_py_xincref_tmp = (PyObject *)(op); \ if (op != NULL) {
if (_py_xincref_tmp != NULL) \ Py_INCREF(op);
Py_INCREF(_py_xincref_tmp); \ }
} while (0) }
#define Py_XDECREF(op) \ #define Py_XINCREF(op) _Py_XINCREF((PyObject *)(op))
do { \
PyObject *_py_xdecref_tmp = (PyObject *)(op); \ static inline void _Py_XDECREF(PyObject *op)
if (_py_xdecref_tmp != NULL) \ {
Py_DECREF(_py_xdecref_tmp); \ if (op != NULL) {
} while (0) Py_DECREF(op);
}
}
#define Py_XDECREF(op) _Py_XDECREF((PyObject *)(op))
#ifndef Py_LIMITED_API #ifndef Py_LIMITED_API
/* Safely decref `op` and set `op` to `op2`. /* Safely decref `op` and set `op` to `op2`.
......
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