@@ -160,7 +160,7 @@ _PyCompile_EnsureArrayLargeEnough(int idx, void **array, int *alloc,
160160 if (idx >= new_alloc ) {
161161 new_alloc = idx + default_alloc ;
162162 }
163- arr = PyObject_Calloc (new_alloc , item_size );
163+ arr = PyMem_Calloc (new_alloc , item_size );
164164 if (arr == NULL ) {
165165 PyErr_NoMemory ();
166166 return ERROR ;
@@ -181,7 +181,7 @@ _PyCompile_EnsureArrayLargeEnough(int idx, void **array, int *alloc,
181181 }
182182
183183 assert (newsize > 0 );
184- void * tmp = PyObject_Realloc (arr , newsize );
184+ void * tmp = PyMem_Realloc (arr , newsize );
185185 if (tmp == NULL ) {
186186 PyErr_NoMemory ();
187187 return ERROR ;
@@ -282,10 +282,10 @@ instr_sequence_insert_instruction(instr_sequence *seq, int pos,
282282
283283static void
284284instr_sequence_fini (instr_sequence * seq ) {
285- PyObject_Free (seq -> s_labelmap );
285+ PyMem_Free (seq -> s_labelmap );
286286 seq -> s_labelmap = NULL ;
287287
288- PyObject_Free (seq -> s_instrs );
288+ PyMem_Free (seq -> s_instrs );
289289 seq -> s_instrs = NULL ;
290290}
291291
@@ -690,7 +690,7 @@ compiler_unit_free(struct compiler_unit *u)
690690 Py_CLEAR (u -> u_metadata .u_cellvars );
691691 Py_CLEAR (u -> u_metadata .u_fasthidden );
692692 Py_CLEAR (u -> u_private );
693- PyObject_Free (u );
693+ PyMem_Free (u );
694694}
695695
696696static int
@@ -1262,8 +1262,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
12621262
12631263 struct compiler_unit * u ;
12641264
1265- u = (struct compiler_unit * )PyObject_Calloc (1 , sizeof (
1266- struct compiler_unit ));
1265+ u = (struct compiler_unit * )PyMem_Calloc (1 , sizeof (struct compiler_unit ));
12671266 if (!u ) {
12681267 PyErr_NoMemory ();
12691268 return ERROR ;
@@ -6657,7 +6656,7 @@ ensure_fail_pop(struct compiler *c, pattern_context *pc, Py_ssize_t n)
66576656 return SUCCESS ;
66586657 }
66596658 Py_ssize_t needed = sizeof (jump_target_label ) * size ;
6660- jump_target_label * resized = PyObject_Realloc (pc -> fail_pop , needed );
6659+ jump_target_label * resized = PyMem_Realloc (pc -> fail_pop , needed );
66616660 if (resized == NULL ) {
66626661 PyErr_NoMemory ();
66636662 return ERROR ;
@@ -6696,13 +6695,13 @@ emit_and_reset_fail_pop(struct compiler *c, location loc,
66966695 USE_LABEL (c , pc -> fail_pop [pc -> fail_pop_size ]);
66976696 if (codegen_addop_noarg (INSTR_SEQUENCE (c ), POP_TOP , loc ) < 0 ) {
66986697 pc -> fail_pop_size = 0 ;
6699- PyObject_Free (pc -> fail_pop );
6698+ PyMem_Free (pc -> fail_pop );
67006699 pc -> fail_pop = NULL ;
67016700 return ERROR ;
67026701 }
67036702 }
67046703 USE_LABEL (c , pc -> fail_pop [0 ]);
6705- PyObject_Free (pc -> fail_pop );
6704+ PyMem_Free (pc -> fail_pop );
67066705 pc -> fail_pop = NULL ;
67076706 return SUCCESS ;
67086707}
@@ -7206,7 +7205,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
72067205 Py_DECREF (pc -> stores );
72077206 * pc = old_pc ;
72087207 Py_INCREF (pc -> stores );
7209- // Need to NULL this for the PyObject_Free call in the error block.
7208+ // Need to NULL this for the PyMem_Free call in the error block.
72107209 old_pc .fail_pop = NULL ;
72117210 // No match. Pop the remaining copy of the subject and fail:
72127211 if (codegen_addop_noarg (INSTR_SEQUENCE (c ), POP_TOP , LOC (p )) < 0 ||
@@ -7252,7 +7251,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
72527251diff :
72537252 compiler_error (c , LOC (p ), "alternative patterns bind different names" );
72547253error :
7255- PyObject_Free (old_pc .fail_pop );
7254+ PyMem_Free (old_pc .fail_pop );
72567255 Py_DECREF (old_pc .stores );
72577256 Py_XDECREF (control );
72587257 return ERROR ;
@@ -7453,7 +7452,7 @@ compiler_match(struct compiler *c, stmt_ty s)
74537452 pattern_context pc ;
74547453 pc .fail_pop = NULL ;
74557454 int result = compiler_match_inner (c , s , & pc );
7456- PyObject_Free (pc .fail_pop );
7455+ PyMem_Free (pc .fail_pop );
74577456 return result ;
74587457}
74597458
0 commit comments