mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-40521: Cleanup code of free lists (GH-21082)
Add get_xxx_state() function to factorize duplicated code.
This commit is contained in:
parent
bc43f6e212
commit
522691c46e
8 changed files with 110 additions and 69 deletions
|
@ -66,6 +66,14 @@ static int
|
|||
contextvar_del(PyContextVar *var);
|
||||
|
||||
|
||||
static struct _Py_context_state *
|
||||
get_context_state(void)
|
||||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
return &interp->context;
|
||||
}
|
||||
|
||||
|
||||
PyObject *
|
||||
_PyContext_NewHamtForTests(void)
|
||||
{
|
||||
|
@ -332,8 +340,7 @@ class _contextvars.Context "PyContext *" "&PyContext_Type"
|
|||
static inline PyContext *
|
||||
_context_alloc(void)
|
||||
{
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
struct _Py_context_state *state = &interp->context;
|
||||
struct _Py_context_state *state = get_context_state();
|
||||
PyContext *ctx;
|
||||
#ifdef Py_DEBUG
|
||||
// _context_alloc() must not be called after _PyContext_Fini()
|
||||
|
@ -462,8 +469,7 @@ context_tp_dealloc(PyContext *self)
|
|||
}
|
||||
(void)context_tp_clear(self);
|
||||
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
struct _Py_context_state *state = &interp->context;
|
||||
struct _Py_context_state *state = get_context_state();
|
||||
#ifdef Py_DEBUG
|
||||
// _context_alloc() must not be called after _PyContext_Fini()
|
||||
assert(state->numfree != -1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue