Skip to content

Commit cc0d5e5

Browse files
committed
Use heap type for malloc info struct
1 parent 716a5f3 commit cc0d5e5

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Python/sysmodule.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ PyDoc_STRVAR(malloc_info__doc__,
19441944
\n\
19451945
Memory allocator info as a named tuple.");
19461946

1947-
static PyTypeObject MallocInfoType;
1947+
static PyTypeObject *MallocInfoType;
19481948

19491949
static PyStructSequence_Field malloc_info_fields[] = {
19501950
{"allocator", "current memory allocator"},
@@ -1970,7 +1970,7 @@ make_malloc_info(void)
19701970
PyObject *v;
19711971
int pos = 0;
19721972

1973-
malloc_info = PyStructSequence_New(&MallocInfoType);
1973+
malloc_info = PyStructSequence_New(MallocInfoType);
19741974
if (malloc_info == NULL) {
19751975
return NULL;
19761976
}
@@ -3228,10 +3228,9 @@ _PySys_InitCore(PyThreadState *tstate, PyObject *sysdict)
32283228
SET_SYS("thread_info", PyThread_GetInfo());
32293229

32303230
/* malloc_info */
3231-
if (MallocInfoType.tp_name == NULL) {
3232-
if (_PyStructSequence_InitType(&MallocInfoType,
3233-
&malloc_info_desc,
3234-
Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
3231+
if (MallocInfoType == NULL) {
3232+
MallocInfoType = PyStructSequence_NewType(&malloc_info_desc);
3233+
if (MallocInfoType == NULL) {
32353234
goto type_init_failed;
32363235
}
32373236
}
@@ -3503,7 +3502,7 @@ _PySys_Fini(PyInterpreterState *interp)
35033502
#ifdef __EMSCRIPTEN__
35043503
Py_CLEAR(EmscriptenInfoType);
35053504
#endif
3506-
_PyStructSequence_FiniType(&MallocInfoType);
3505+
Py_CLEAR(MallocInfoType);
35073506
}
35083507
}
35093508

0 commit comments

Comments
 (0)