if (idx >= new_alloc) {
new_alloc = idx + default_alloc;
}
- arr = PyObject_Calloc(new_alloc, item_size);
+ arr = PyMem_Calloc(new_alloc, item_size);
if (arr == NULL) {
PyErr_NoMemory();
return ERROR;
}
assert(newsize > 0);
- void *tmp = PyObject_Realloc(arr, newsize);
+ void *tmp = PyMem_Realloc(arr, newsize);
if (tmp == NULL) {
PyErr_NoMemory();
return ERROR;
static void
instr_sequence_fini(instr_sequence *seq) {
- PyObject_Free(seq->s_labelmap);
+ PyMem_Free(seq->s_labelmap);
seq->s_labelmap = NULL;
- PyObject_Free(seq->s_instrs);
+ PyMem_Free(seq->s_instrs);
seq->s_instrs = NULL;
}
Py_CLEAR(u->u_metadata.u_cellvars);
Py_CLEAR(u->u_metadata.u_fasthidden);
Py_CLEAR(u->u_private);
- PyObject_Free(u);
+ PyMem_Free(u);
}
static int
struct compiler_unit *u;
- u = (struct compiler_unit *)PyObject_Calloc(1, sizeof(
- struct compiler_unit));
+ u = (struct compiler_unit *)PyMem_Calloc(1, sizeof(struct compiler_unit));
if (!u) {
PyErr_NoMemory();
return ERROR;
return SUCCESS;
}
Py_ssize_t needed = sizeof(jump_target_label) * size;
- jump_target_label *resized = PyObject_Realloc(pc->fail_pop, needed);
+ jump_target_label *resized = PyMem_Realloc(pc->fail_pop, needed);
if (resized == NULL) {
PyErr_NoMemory();
return ERROR;
USE_LABEL(c, pc->fail_pop[pc->fail_pop_size]);
if (codegen_addop_noarg(INSTR_SEQUENCE(c), POP_TOP, loc) < 0) {
pc->fail_pop_size = 0;
- PyObject_Free(pc->fail_pop);
+ PyMem_Free(pc->fail_pop);
pc->fail_pop = NULL;
return ERROR;
}
}
USE_LABEL(c, pc->fail_pop[0]);
- PyObject_Free(pc->fail_pop);
+ PyMem_Free(pc->fail_pop);
pc->fail_pop = NULL;
return SUCCESS;
}
Py_DECREF(pc->stores);
*pc = old_pc;
Py_INCREF(pc->stores);
- // Need to NULL this for the PyObject_Free call in the error block.
+ // Need to NULL this for the PyMem_Free call in the error block.
old_pc.fail_pop = NULL;
// No match. Pop the remaining copy of the subject and fail:
if (codegen_addop_noarg(INSTR_SEQUENCE(c), POP_TOP, LOC(p)) < 0 ||
diff:
compiler_error(c, LOC(p), "alternative patterns bind different names");
error:
- PyObject_Free(old_pc.fail_pop);
+ PyMem_Free(old_pc.fail_pop);
Py_DECREF(old_pc.stores);
Py_XDECREF(control);
return ERROR;
pattern_context pc;
pc.fail_pop = NULL;
int result = compiler_match_inner(c, s, &pc);
- PyObject_Free(pc.fail_pop);
+ PyMem_Free(pc.fail_pop);
return result;
}
static basicblock *
cfg_builder_new_block(cfg_builder *g)
{
- basicblock *b = (basicblock *)PyObject_Calloc(1, sizeof(basicblock));
+ basicblock *b = (basicblock *)PyMem_Calloc(1, sizeof(basicblock));
if (b == NULL) {
PyErr_NoMemory();
return NULL;
basicblock *b = g->g_block_list;
while (b != NULL) {
if (b->b_instr) {
- PyObject_Free((void *)b->b_instr);
+ PyMem_Free((void *)b->b_instr);
}
basicblock *next = b->b_list;
- PyObject_Free((void *)b);
+ PyMem_Free((void *)b);
b = next;
}
PyMem_Free(g);