summaryrefslogtreecommitdiffstats
path: root/Parser/parsetok.c
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 /Parser/parsetok.c
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 'Parser/parsetok.c')
-rw-r--r--Parser/parsetok.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index cd3887d..5758fa74 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -133,7 +133,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
else
started = 1;
len = b - a; /* XXX this may compute NULL - NULL */
- str = PyMem_NEW(char, len + 1);
+ str = (char *) PyObject_MALLOC(len + 1);
if (str == NULL) {
fprintf(stderr, "no mem for next token\n");
err_ret->error = E_NOMEM;
@@ -157,7 +157,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
PyParser_AddToken(ps, (int)type, str, tok->lineno,
&(err_ret->expected))) != E_OK) {
if (err_ret->error != E_DONE)
- PyMem_DEL(str);
+ PyObject_FREE(str);
break;
}
}
@@ -178,7 +178,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
err_ret->offset = tok->cur - tok->buf;
if (tok->buf != NULL) {
size_t len = tok->inp - tok->buf;
- err_ret->text = PyMem_NEW(char, len + 1);
+ err_ret->text = (char *) PyObject_MALLOC(len + 1);
if (err_ret->text != NULL) {
if (len > 0)
strncpy(err_ret->text, tok->buf, len);