@@ -747,7 +747,8 @@ free_threadstate(PyThreadState *tstate)
747747 */
748748
749749static void
750- init_threadstate (PyThreadState * tstate , PyInterpreterState * interp , uint64_t id ,
750+ init_threadstate (PyThreadState * tstate ,
751+ PyInterpreterState * interp , uint64_t id ,
751752 PyThreadState * next )
752753{
753754 if (tstate -> _initialized ) {
@@ -795,11 +796,6 @@ new_threadstate(PyInterpreterState *interp)
795796 PyThreadState * tstate ;
796797 _PyRuntimeState * runtime = interp -> runtime ;
797798
798- _PyStackChunk * datastack_chunk = allocate_chunk (DATA_STACK_CHUNK_SIZE , NULL );
799- if (datastack_chunk == NULL ) {
800- return NULL ;
801- }
802-
803799 /* We serialize concurrent creation to protect global state. */
804800 HEAD_LOCK (runtime );
805801
@@ -836,7 +832,6 @@ new_threadstate(PyInterpreterState *interp)
836832
837833error :
838834 HEAD_UNLOCK (runtime );
839- _PyObject_VirtualFree (datastack_chunk , datastack_chunk -> size );
840835 return NULL ;
841836}
842837
@@ -2196,9 +2191,9 @@ push_chunk(PyThreadState *tstate, int size)
21962191 }
21972192 tstate -> datastack_chunk = new ;
21982193 tstate -> datastack_limit = (PyObject * * )(((char * )new ) + allocate_size );
2199- // When new is the "root" chunk (new->previous == NULL), we keep
2194+ // When new is the "root" chunk (i.e. new->previous == NULL), we can keep
22002195 // _PyThreadState_PopFrame from freeing it later by "skipping" over the
2201- // first element.
2196+ // first element:
22022197 PyObject * * res = & new -> data [new -> previous == NULL ];
22032198 tstate -> datastack_top = res + size ;
22042199 return res ;
0 commit comments