mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
gh-102304: Consolidate Direct Usage of _Py_RefTotal (gh-102514)
This simplifies further changes to _Py_RefTotal (e.g. make it atomic or move it to PyInterpreterState). https://github.com/python/cpython/issues/102304
This commit is contained in:
parent
11a2c6ce51
commit
cbb0aa71d0
10 changed files with 127 additions and 45 deletions
|
|
@ -930,10 +930,6 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
|
|||
return *pv == NULL ? -1 : 0;
|
||||
}
|
||||
|
||||
/* XXX UNREF/NEWREF interface should be more symmetrical */
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_RefTotal--;
|
||||
#endif
|
||||
if (_PyObject_GC_IS_TRACKED(v)) {
|
||||
_PyObject_GC_UNTRACK(v);
|
||||
}
|
||||
|
|
@ -947,10 +943,13 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize)
|
|||
sv = PyObject_GC_Resize(PyTupleObject, v, newsize);
|
||||
if (sv == NULL) {
|
||||
*pv = NULL;
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_DecRefTotal();
|
||||
#endif
|
||||
PyObject_GC_Del(v);
|
||||
return -1;
|
||||
}
|
||||
_Py_NewReference((PyObject *) sv);
|
||||
_Py_NewReferenceNoTotal((PyObject *) sv);
|
||||
/* Zero out items added by growing */
|
||||
if (newsize > oldsize)
|
||||
memset(&sv->ob_item[oldsize], 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue