8000 gh-102304: Consolidate Direct Usage of _Py_RefTotal by ericsnowcurrently · Pull Request #102514 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-102304: Consolidate Direct Usage of _Py_RefTotal #102514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add _Py_DEC_REFTOTAL() in pycore_object.h.
  • Loading branch information
ericsnowcurrently committed Mar 8, 2023
commit 240d1d5e8312778f9c2a9dc07cc4845ad6b90dbe
9 changes: 7 additions & 2 deletions Include/internal/pycore_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
extern void _Py_AddRefTotal(Py_ssize_t);
extern void _Py_IncRefTotal(void);
extern void _Py_DecRefTotal(void);
# define _Py_DEC_REFTOTAL() _Py_RefTotal--
#endif

// Increment reference count by n
Expand All @@ -63,7 +64,7 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
{
_Py_DECREF_STAT_INC();
#ifdef Py_REF_DEBUG
_Py_RefTotal--;
_Py_DEC_REFTOTAL();
#endif
if (--op->ob_refcnt != 0) {
assert(op->ob_refcnt > 0);
Expand All @@ -81,7 +82,7 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
{
_Py_DECREF_STAT_INC();
#ifdef Py_REF_DEBUG
_Py_RefTotal--;
_Py_DEC_REFTOTAL();
#endif
op->ob_refcnt--;
#ifdef Py_DEBUG
Expand All @@ -91,6 +92,10 @@ _Py_DECREF_NO_DEALLOC(PyObject *op)
#endif
}

#ifdef Py_REF_DEBUG
# undef _Py_DEC_REFTOTAL
#endif


PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type);
PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
Expand Down
0