@@ -160,7 +160,7 @@ _PyCompile_EnsureArrayLargeEnough(int idx, void **array, int *alloc,
160
160
if (idx >= new_alloc ) {
161
161
new_alloc = idx + default_alloc ;
162
162
}
163
- arr = PyObject_Calloc (new_alloc , item_size );
163
+ arr = PyMem_Calloc (new_alloc , item_size );
164
164
if (arr == NULL ) {
165
165
PyErr_NoMemory ();
166
166
return ERROR ;
@@ -181,7 +181,7 @@ _PyCompile_EnsureArrayLargeEnough(int idx, void **array, int *alloc,
181
181
}
182
182
183
183
assert (newsize > 0 );
184
- void * tmp = PyObject_Realloc (arr , newsize );
184
+ void * tmp = PyMem_Realloc (arr , newsize );
185
185
if (tmp == NULL ) {
186
186
PyErr_NoMemory ();
187
187
return ERROR ;
@@ -282,10 +282,10 @@ instr_sequence_insert_instruction(instr_sequence *seq, int pos,
282
282
283
283
static void
284
284
instr_sequence_fini (instr_sequence * seq ) {
285
- PyObject_Free (seq -> s_labelmap );
285
+ PyMem_Free (seq -> s_labelmap );
286
286
seq -> s_labelmap = NULL ;
287
287
288
- PyObject_Free (seq -> s_instrs );
288
+ PyMem_Free (seq -> s_instrs );
289
289
seq -> s_instrs = NULL ;
290
290
}
291
291
@@ -690,7 +690,7 @@ compiler_unit_free(struct compiler_unit *u)
690
690
Py_CLEAR (u -> u_metadata .u_cellvars );
691
691
Py_CLEAR (u -> u_metadata .u_fasthidden );
692
692
Py_CLEAR (u -> u_private );
693
- PyObject_Free (u );
693
+ PyMem_Free (u );
694
694
}
695
695
696
696
static int
@@ -1262,8 +1262,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
1262
1262
1263
1263
struct compiler_unit * u ;
1264
1264
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 ));
1267
1266
if (!u ) {
1268
1267
PyErr_NoMemory ();
1269
1268
return ERROR ;
@@ -6657,7 +6656,7 @@ ensure_fail_pop(struct compiler *c, pattern_context *pc, Py_ssize_t n)
6657
6656
return SUCCESS ;
6658
6657
}
6659
6658
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 );
6661
6660
if (resized == NULL ) {
6662
6661
PyErr_NoMemory ();
6663
6662
return ERROR ;
@@ -6696,13 +6695,13 @@ emit_and_reset_fail_pop(struct compiler *c, location loc,
6696
6695
USE_LABEL (c , pc -> fail_pop [pc -> fail_pop_size ]);
6697
6696
if (codegen_addop_noarg (INSTR_SEQUENCE (c ), POP_TOP , loc ) < 0 ) {
6698
6697
pc -> fail_pop_size = 0 ;
6699
- PyObject_Free (pc -> fail_pop );
6698
+ PyMem_Free (pc -> fail_pop );
6700
6699
pc -> fail_pop = NULL ;
6701
6700
return ERROR ;
6702
6701
}
6703
6702
}
6704
6703
USE_LABEL (c , pc -> fail_pop [0 ]);
6705
- PyObject_Free (pc -> fail_pop );
6704
+ PyMem_Free (pc -> fail_pop );
6706
6705
pc -> fail_pop = NULL ;
6707
6706
return SUCCESS ;
6708
6707
}
@@ -7206,7 +7205,7 @@ compiler_pattern_or(struct compiler *c, pattern_ty p, pattern_context *pc)
7206
7205
Py_DECREF (pc -> stores );
7207
7206
* pc = old_pc ;
7208
7207
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.
7210
7209
old_pc .fail_pop = NULL ;
7211
7210
// No match. Pop the remaining copy of the subject and fail:
7212
7211
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)
7252
7251
diff :
7253
7252
compiler_error (c , LOC (p ), "alternative patterns bind different names" );
7254
7253
error :
7255
- PyObject_Free (old_pc .fail_pop );
7254
+ PyMem_Free (old_pc .fail_pop );
7256
7255
Py_DECREF (old_pc .stores );
7257
7256
Py_XDECREF (control );
7258
7257
return ERROR ;
@@ -7453,7 +7452,7 @@ compiler_match(struct compiler *c, stmt_ty s)
7453
7452
pattern_context pc ;
7454
7453
pc .fail_pop = NULL ;
7455
7454
int result = compiler_match_inner (c , s , & pc );
7456
- PyObject_Free (pc .fail_pop );
7455
+ PyMem_Free (pc .fail_pop );
7457
7456
return result ;
7458
7457
}
7459
7458
0 commit comments