[Python-checkins] CVS: python/dist/src/Parser myreadline.c,2.16,2.17 parsetok.c,2.15,2.16 pgenmain.c,2.15,2.16 tokenizer.c,2.40,2.41
Guido van Rossum
python-dev@python.org
Wed, 3 May 2000 19:45:11 -0400 (EDT)
- Previous message: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.1,1.2
- Next message: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.2,2.3 _tkinter.c,1.96,1.97 almodule.c,1.23,1.24 arraymodule.c,2.38,2.39 bsddbmodule.c,1.17,1.18 cPickle.c,2.40,2.41 cStringIO.c,2.19,2.20 cdmodule.c,1.18,1.19 clmodule.c,2.19,2.20 cursesmodule.c,2.19,2.20 dbmmodule.c,2.16,2.17 dlmodule.c,2.6,2.7 flmodule.c,1.35,1.36 fmmodule.c,1.10,1.11 gdbmmodule.c,2.21,2.22 getpath.c,1.20,1.21 linuxaudiodev.c,2.1,2.2 md5module.c,2.14,2.15 mmapmodule.c,2.7,2.8 mpzmodule.c,2.22,2.23 newmodule.c,2.19,2.20 nismodule.c,2.15,2.16 parsermodule.c,2.38,2.39 pcremodule.c,2.18,2.19 pyexpat.c,2.3,2.4 readline.c,2.16,2.17 regexmodule.c,1.33,1.34 rotormodule.c,2.22,2.23 selectmodule.c,2.31,2.32 shamodule.c,2.4,2.5 socketmodule.c,1.106,1.107 stropmodule.c,2.62,2.63 sunaudiodev.c,1.16,1.17 svmodule.c,2.10,2.11 threadmodule.c,2.30,2.31 xxmodule.c,2.15,2.16 zlibmodule.c,2.31,2.32
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /projects/cvsroot/python/dist/src/Parser
In directory eric:/projects/python/develop/guido/clean/Parser
Modified Files:
myreadline.c parsetok.c pgenmain.c tokenizer.c
Log Message:
Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.
(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode. I'm also holding back on his
change to main.c, which seems unnecessary to me.)
Index: myreadline.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Parser/myreadline.c,v
retrieving revision 2.16
retrieving revision 2.17
diff -C2 -r2.16 -r2.17
*** myreadline.c 1998/08/29 16:03:27 2.16
--- myreadline.c 2000/05/03 23:44:37 2.17
***************
*** 90,94 ****
char *p;
n = 100;
! if ((p = malloc(n)) == NULL)
return NULL;
fflush(stdout);
--- 90,94 ----
char *p;
n = 100;
! if ((p = PyMem_MALLOC(n)) == NULL)
return NULL;
fflush(stdout);
***************
*** 100,104 ****
break;
case 1: /* Interrupt */
! free(p);
return NULL;
case -1: /* EOF */
--- 100,104 ----
break;
case 1: /* Interrupt */
! PyMem_FREE(p);
return NULL;
case -1: /* EOF */
***************
*** 118,122 ****
while (n > 0 && p[n-1] != '\n') {
int incr = n+2;
! p = realloc(p, n + incr);
if (p == NULL)
return NULL;
--- 118,122 ----
while (n > 0 && p[n-1] != '\n') {
int incr = n+2;
! p = PyMem_REALLOC(p, n + incr);
if (p == NULL)
return NULL;
***************
*** 125,134 ****
n += strlen(p+n);
}
! return realloc(p, n+1);
}
/* By initializing this function pointer, systems embedding Python can
! override the readline function. */
char *(*PyOS_ReadlineFunctionPointer) Py_PROTO((char *));
--- 125,136 ----
n += strlen(p+n);
}
! return PyMem_REALLOC(p, n+1);
}
/* By initializing this function pointer, systems embedding Python can
! override the readline function.
!
! Note: Python expects in return a buffer allocated with PyMem_Malloc. */
char *(*PyOS_ReadlineFunctionPointer) Py_PROTO((char *));
Index: parsetok.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Parser/parsetok.c,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -r2.15 -r2.16
*** parsetok.c 1998/12/21 18:32:40 2.15
--- parsetok.c 2000/05/03 23:44:37 2.16
***************
*** 193,197 ****
if (tok->buf != NULL) {
int len = tok->inp - tok->buf;
! err_ret->text = malloc(len + 1);
if (err_ret->text != NULL) {
if (len > 0)
--- 193,197 ----
if (tok->buf != NULL) {
int len = tok->inp - tok->buf;
! err_ret->text = PyMem_NEW(char, len + 1);
if (err_ret->text != NULL) {
if (len > 0)
Index: pgenmain.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Parser/pgenmain.c,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -r2.15 -r2.16
*** pgenmain.c 1998/08/25 18:12:36 2.15
--- pgenmain.c 2000/05/03 23:44:37 2.16
***************
*** 140,144 ****
}
fprintf(stderr, "^\n");
! free(err.text);
}
Py_Exit(1);
--- 140,144 ----
}
fprintf(stderr, "^\n");
! PyMem_DEL(err.text);
}
Py_Exit(1);
***************
*** 197,201 ****
{
int n = 1000;
! char *p = malloc(n);
char *q;
if (p == NULL)
--- 197,201 ----
{
int n = 1000;
! char *p = PyMem_MALLOC(n);
char *q;
if (p == NULL)
***************
*** 210,214 ****
if (n > 0 && p[n-1] != '\n')
p[n-1] = '\n';
! return realloc(p, n+1);
}
--- 210,214 ----
if (n > 0 && p[n-1] != '\n')
p[n-1] = '\n';
! return PyMem_REALLOC(p, n+1);
}
Index: tokenizer.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Parser/tokenizer.c,v
retrieving revision 2.40
retrieving revision 2.41
diff -C2 -r2.40 -r2.41
*** tokenizer.c 2000/04/03 23:02:17 2.40
--- tokenizer.c 2000/05/03 23:44:37 2.41
***************
*** 220,224 ****
tok->done = E_INTR;
else if (*new == '\0') {
! free(new);
tok->done = E_EOF;
}
--- 220,224 ----
tok->done = E_INTR;
else if (*new == '\0') {
! PyMem_FREE(new);
tok->done = E_EOF;
}
***************
*** 227,236 ****
int oldlen = tok->cur - tok->buf;
int newlen = oldlen + strlen(new);
! char *buf = realloc(tok->buf, newlen+1);
tok->lineno++;
if (buf == NULL) {
! free(tok->buf);
tok->buf = NULL;
! free(new);
tok->done = E_NOMEM;
return EOF;
--- 227,237 ----
int oldlen = tok->cur - tok->buf;
int newlen = oldlen + strlen(new);
! char *buf = tok->buf;
! PyMem_RESIZE(buf, char, newlen+1);
tok->lineno++;
if (buf == NULL) {
! PyMem_DEL(tok->buf);
tok->buf = NULL;
! PyMem_FREE(new);
tok->done = E_NOMEM;
return EOF;
***************
*** 239,243 ****
tok->cur = tok->buf + oldlen;
strcpy(tok->buf + oldlen, new);
! free(new);
tok->inp = tok->buf + newlen;
tok->end = tok->inp + 1;
--- 240,244 ----
tok->cur = tok->buf + oldlen;
strcpy(tok->buf + oldlen, new);
! PyMem_FREE(new);
tok->inp = tok->buf + newlen;
tok->end = tok->inp + 1;
***************
*** 247,251 ****
tok->lineno++;
if (tok->buf != NULL)
! free(tok->buf);
tok->buf = new;
tok->cur = tok->buf;
--- 248,252 ----
tok->lineno++;
if (tok->buf != NULL)
! PyMem_DEL(tok->buf);
tok->buf = new;
tok->cur = tok->buf;
- Previous message: [Python-checkins] CVS: python/dist/src/PC winreg.c,1.1,1.2
- Next message: [Python-checkins] CVS: python/dist/src/Modules _sre.c,2.2,2.3 _tkinter.c,1.96,1.97 almodule.c,1.23,1.24 arraymodule.c,2.38,2.39 bsddbmodule.c,1.17,1.18 cPickle.c,2.40,2.41 cStringIO.c,2.19,2.20 cdmodule.c,1.18,1.19 clmodule.c,2.19,2.20 cursesmodule.c,2.19,2.20 dbmmodule.c,2.16,2.17 dlmodule.c,2.6,2.7 flmodule.c,1.35,1.36 fmmodule.c,1.10,1.11 gdbmmodule.c,2.21,2.22 getpath.c,1.20,1.21 linuxaudiodev.c,2.1,2.2 md5module.c,2.14,2.15 mmapmodule.c,2.7,2.8 mpzmodule.c,2.22,2.23 newmodule.c,2.19,2.20 nismodule.c,2.15,2.16 parsermodule.c,2.38,2.39 pcremodule.c,2.18,2.19 pyexpat.c,2.3,2.4 readline.c,2.16,2.17 regexmodule.c,1.33,1.34 rotormodule.c,2.22,2.23 selectmodule.c,2.31,2.32 shamodule.c,2.4,2.5 socketmodule.c,1.106,1.107 stropmodule.c,2.62,2.63 sunaudiodev.c,1.16,1.17 svmodule.c,2.10,2.11 threadmodule.c,2.30,2.31 xxmodule.c,2.15,2.16 zlibmodule.c,2.31,2.32
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]