summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2002-08-04 06:28:21 (GMT)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2002-08-04 06:28:21 (GMT)
commit80d4e2acf58433fb2e84ee55d183a7995dc44d0e (patch)
treee4c33fd6d334c9f5bf5fd5260249fd650202c445 /Python
parent4104db39b8c8a85b884bbba051d21b7ea1d21ee1 (diff)
downloadcpython-80d4e2acf58433fb2e84ee55d183a7995dc44d0e.zip
cpython-80d4e2acf58433fb2e84ee55d183a7995dc44d0e.tar.gz
cpython-80d4e2acf58433fb2e84ee55d183a7995dc44d0e.tar.bz2
SF patch #578297:
Change the parser and compiler to use PyMalloc. Only the files implementing processes that will request memory allocations small enough for PyMalloc to be a win have been changed, which are:- - Python/compile.c - Parser/acceler.c - Parser/node.c - Parser/parsetok.c This augments the aggressive overallocation strategy implemented by Tim Peters in PyNode_AddChild() [Parser/node.c], in reducing the impact of platform malloc()/realloc()/free() corner case behaviour. Such corner cases are known to be triggered by test_longexp and test_import. Jeremy Hylton, in accepting this patch, recommended this as a bugfix candidate for 2.2. While the changes to Python/compile.c and Parser/node.c backport easily (and could go in), the changes to Parser/acceler.c and Parser/parsetok.c require other not insignificant changes as a result of the differences in the memory APIs between 2.3 and 2.2, which I'm not in a position to work through at the moment. This is a pity, as the Parser/parsetok.c changes are the most important after the Parser/node.c changes, due to the size of the memory requests involved and their frequency.
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 2966532..3a0948e 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -719,7 +719,7 @@ com_free(struct compiling *c)
Py_XDECREF(c->c_cellvars);
Py_XDECREF(c->c_lnotab);
if (c->c_future)
- PyMem_Free((void *)c->c_future);
+ PyObject_FREE((void *)c->c_future);
}
static void
@@ -2020,7 +2020,7 @@ com_factor(struct compiling *c, node *n)
return;
}
if (childtype == MINUS) {
- char *s = PyMem_Malloc(strlen(STR(pnum)) + 2);
+ char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2);
if (s == NULL) {
com_error(c, PyExc_MemoryError, "");
com_addbyte(c, 255);
@@ -2028,7 +2028,7 @@ com_factor(struct compiling *c, node *n)
}
s[0] = '-';
strcpy(s + 1, STR(pnum));
- PyMem_Free(STR(pnum));
+ PyObject_FREE(STR(pnum));
STR(pnum) = s;
}
com_atom(c, patom);
@@ -4116,7 +4116,7 @@ PyNode_CompileSymtable(node *n, char *filename)
st = symtable_init();
if (st == NULL) {
- PyMem_Free((void *)ff);
+ PyObject_FREE((void *)ff);
return NULL;
}
st->st_future = ff;
@@ -4129,7 +4129,7 @@ PyNode_CompileSymtable(node *n, char *filename)
return st;
fail:
- PyMem_Free((void *)ff);
+ PyObject_FREE((void *)ff);
st->st_future = NULL;
PySymtable_Free(st);
return NULL;
@@ -4722,7 +4722,7 @@ symtable_init()
{
struct symtable *st;
- st = (struct symtable *)PyMem_Malloc(sizeof(struct symtable));
+ st = (struct symtable *)PyObject_MALLOC(sizeof(struct symtable));
if (st == NULL)
return NULL;
st->st_pass = 1;
@@ -4749,7 +4749,7 @@ PySymtable_Free(struct symtable *st)
Py_XDECREF(st->st_symbols);
Py_XDECREF(st->st_stack);
Py_XDECREF(st->st_cur);
- PyMem_Free((void *)st);
+ PyObject_FREE((void *)st);
}
/* When the compiler exits a scope, it must should update the scope's