[Python-checkins] python/dist/src/Python compile.c,2.248,2.249
aimacintyre@users.sourceforge.net
aimacintyre@users.sourceforge.net
Sat, 03 Aug 2002 23:28:23 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv6008
Modified Files:
compile.c
Log Message:
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.
Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.248
retrieving revision 2.249
diff -C2 -d -r2.248 -r2.249
*** compile.c 25 Jul 2002 06:18:42 -0000 2.248
--- compile.c 4 Aug 2002 06:28:21 -0000 2.249
***************
*** 720,724 ****
Py_XDECREF(c->c_lnotab);
if (c->c_future)
! PyMem_Free((void *)c->c_future);
}
--- 720,724 ----
Py_XDECREF(c->c_lnotab);
if (c->c_future)
! PyObject_FREE((void *)c->c_future);
}
***************
*** 2021,2025 ****
}
if (childtype == MINUS) {
! char *s = PyMem_Malloc(strlen(STR(pnum)) + 2);
if (s == NULL) {
com_error(c, PyExc_MemoryError, "");
--- 2021,2025 ----
}
if (childtype == MINUS) {
! char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2);
if (s == NULL) {
com_error(c, PyExc_MemoryError, "");
***************
*** 2029,2033 ****
s[0] = '-';
strcpy(s + 1, STR(pnum));
! PyMem_Free(STR(pnum));
STR(pnum) = s;
}
--- 2029,2033 ----
s[0] = '-';
strcpy(s + 1, STR(pnum));
! PyObject_FREE(STR(pnum));
STR(pnum) = s;
}
***************
*** 4117,4121 ****
st = symtable_init();
if (st == NULL) {
! PyMem_Free((void *)ff);
return NULL;
}
--- 4117,4121 ----
st = symtable_init();
if (st == NULL) {
! PyObject_FREE((void *)ff);
return NULL;
}
***************
*** 4130,4134 ****
return st;
fail:
! PyMem_Free((void *)ff);
st->st_future = NULL;
PySymtable_Free(st);
--- 4130,4134 ----
return st;
fail:
! PyObject_FREE((void *)ff);
st->st_future = NULL;
PySymtable_Free(st);
***************
*** 4723,4727 ****
struct symtable *st;
! st = (struct symtable *)PyMem_Malloc(sizeof(struct symtable));
if (st == NULL)
return NULL;
--- 4723,4727 ----
struct symtable *st;
! st = (struct symtable *)PyObject_MALLOC(sizeof(struct symtable));
if (st == NULL)
return NULL;
***************
*** 4750,4754 ****
Py_XDECREF(st->st_stack);
Py_XDECREF(st->st_cur);
! PyMem_Free((void *)st);
}
--- 4750,4754 ----
Py_XDECREF(st->st_stack);
Py_XDECREF(st->st_cur);
! PyObject_FREE((void *)st);
}