From 9c9a7a69d4cf8a0dfb563ac51ed59c3b00f9a9cf Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 24 Oct 2018 16:24:59 +0200 Subject: [PATCH] bpo-35059: Convert _Py_NewReference() to function Convert _Py_NewReference() and _Py_ForgetReference() macros to static inline functions. --- Include/object.h | 15 ++++++++++----- .../2018-10-24-16-45-26.bpo-35059.jhoVMQ.rst | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/C API/2018-10-24-16-45-26.bpo-35059.jhoVMQ.rst diff --git a/Include/object.h b/Include/object.h index bcf78afe6bbb17..8e854d9a16404c 100644 --- a/Include/object.h +++ b/Include/object.h @@ -775,12 +775,17 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); /* Without Py_TRACE_REFS, there's little enough to do that we expand code * inline. */ -#define _Py_NewReference(op) ( \ - _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ - _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - Py_REFCNT(op) = 1) +static inline void _Py_NewReference(PyObject *op) +{ + _Py_INC_TPALLOCS(op); + _Py_INC_REFTOTAL; + Py_REFCNT(op) = 1; +} -#define _Py_ForgetReference(op) _Py_INC_TPFREES(op) +static inline void _Py_ForgetReference(PyObject *op) +{ + _Py_INC_TPFREES(op); +} #ifdef Py_LIMITED_API PyAPI_FUNC(void) _Py_Dealloc(PyObject *); diff --git a/Misc/NEWS.d/next/C API/2018-10-24-16-45-26.bpo-35059.jhoVMQ.rst b/Misc/NEWS.d/next/C API/2018-10-24-16-45-26.bpo-35059.jhoVMQ.rst new file mode 100644 index 00000000000000..6863215c1932d7 --- /dev/null +++ b/Misc/NEWS.d/next/C API/2018-10-24-16-45-26.bpo-35059.jhoVMQ.rst @@ -0,0 +1,2 @@ +Convert :c:func:`_Py_NewReference` and :c:func:`_Py_ForgetReference` macros +to static inline functions.