@@ -26,17 +26,13 @@ class float "PyObject *" "&PyFloat_Type"
26
26
27
27
#include "clinic/floatobject.c.h"
28
28
29
- #ifndef PyFloat_MAXFREELIST
30
- # define PyFloat_MAXFREELIST 100
31
- #endif
32
-
33
-
34
29
#if PyFloat_MAXFREELIST > 0
35
30
static struct _Py_float_state *
36
31
get_float_state (void )
37
32
{
38
- PyInterpreterState * interp = _PyInterpreterState_GET ();
39
- return & interp -> float_state ;
33
+ _PyFreeListState * state = _PyFreeListState_GET ();
34
+ assert (state != NULL );
35
+ return & state -> float_state ;
40
36
}
41
37
#endif
42
38
@@ -2002,29 +1998,30 @@ _PyFloat_InitTypes(PyInterpreterState *interp)
2002
1998
}
2003
1999
2004
2000
void
2005
- _PyFloat_ClearFreeList (PyInterpreterState * interp )
2001
+ _PyFloat_ClearFreeList (_PyFreeListState * freelist_state , int is_finalization )
2006
2002
{
2007
2003
#if PyFloat_MAXFREELIST > 0
2008
- struct _Py_float_state * state = & interp -> float_state ;
2004
+ struct _Py_float_state * state = & freelist_state -> float_state ;
2009
2005
PyFloatObject * f = state -> free_list ;
2010
2006
while (f != NULL ) {
2011
2007
PyFloatObject * next = (PyFloatObject * ) Py_TYPE (f );
2012
2008
PyObject_Free (f );
2013
2009
f = next ;
2014
2010
}
2015
2011
state -> free_list = NULL ;
2016
- state -> numfree = 0 ;
2012
+ if (is_finalization ) {
2013
+ state -> numfree = -1 ;
2014
+ }
2015
+ else {
2016
+ state -> numfree = 0 ;
2017
+ }
2017
2018
#endif
2018
2019
}
2019
2020
2020
2021
void
2021
- _PyFloat_Fini (PyInterpreterState * interp )
2022
+ _PyFloat_Fini (_PyFreeListState * state )
2022
2023
{
2023
- _PyFloat_ClearFreeList (interp );
2024
- #if defined(Py_DEBUG ) && PyFloat_MAXFREELIST > 0
2025
- struct _Py_float_state * state = & interp -> float_state ;
2026
- state -> numfree = -1 ;
2027
- #endif
2024
+ _PyFloat_ClearFreeList (state , 1 );
2028
2025
}
2029
2026
2030
2027
void
0 commit comments