[Python-checkins] r51026 - in python/branches/bcannon-sandboxing: Include/pymem.h Parser/pgenmain.c Parser/tokenizer.c
brett.cannon
python-checkins at python.org
Tue Aug 1 22:23:36 CEST 2006
Author: brett.cannon
Date: Tue Aug 1 22:23:34 2006
New Revision: 51026
Modified:
python/branches/bcannon-sandboxing/Include/pymem.h
python/branches/bcannon-sandboxing/Parser/pgenmain.c
python/branches/bcannon-sandboxing/Parser/tokenizer.c
Log:
Finish converting Parser/* to be usable in face of tracked memory.
Modified: python/branches/bcannon-sandboxing/Include/pymem.h
==============================================================================
--- python/branches/bcannon-sandboxing/Include/pymem.h (original)
+++ python/branches/bcannon-sandboxing/Include/pymem.h Tue Aug 1 22:23:34 2006
@@ -73,7 +73,7 @@
#endif /* PYMALLOC_DEBUG */
-#ifdef PYMALLOC
+#ifdef WITH_PYMALLOC
#define PyMem_RAW_MALLOC PyObject_Malloc
#define PyMem_RAW_REALLOC PyObject_Realloc
#define PyMem_RAW_FREE PyObject_Free
Modified: python/branches/bcannon-sandboxing/Parser/pgenmain.c
==============================================================================
--- python/branches/bcannon-sandboxing/Parser/pgenmain.c (original)
+++ python/branches/bcannon-sandboxing/Parser/pgenmain.c Tue Aug 1 22:23:34 2006
@@ -104,7 +104,7 @@
putc(' ', stderr);
}
fprintf(stderr, "^\n");
- PyObject_FREE(err.text);
+ PyObject_Free(err.text);
}
Py_Exit(1);
}
@@ -136,7 +136,7 @@
PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
{
size_t n = 1000;
- char *p = (char *)PyMem_MALLOC(n);
+ char *p = (char *)PyMem_RAW_MALLOC(n);
char *q;
if (p == NULL)
return NULL;
@@ -149,7 +149,7 @@
n = strlen(p);
if (n > 0 && p[n-1] != '\n')
p[n-1] = '\n';
- return (char *)PyMem_REALLOC(p, n+1);
+ return (char *)PyMem_RAW_REALLOC(p, n+1);
}
/* No-nonsense fgets */
Modified: python/branches/bcannon-sandboxing/Parser/tokenizer.c
==============================================================================
--- python/branches/bcannon-sandboxing/Parser/tokenizer.c (original)
+++ python/branches/bcannon-sandboxing/Parser/tokenizer.c Tue Aug 1 22:23:34 2006
@@ -105,7 +105,7 @@
static struct tok_state *
tok_new(void)
{
- struct tok_state *tok = (struct tok_state *)PyMem_MALLOC(
+ struct tok_state *tok = (struct tok_state *)PyMem_RAW_MALLOC(
sizeof(struct tok_state));
if (tok == NULL)
return NULL;
@@ -657,7 +657,7 @@
struct tok_state *tok = tok_new();
if (tok == NULL)
return NULL;
- if ((tok->buf = (char *)PyMem_MALLOC(BUFSIZ)) == NULL) {
+ if ((tok->buf = (char *)PyMem_RAW_MALLOC(BUFSIZ)) == NULL) {
PyTokenizer_Free(tok);
return NULL;
}
@@ -676,14 +676,14 @@
PyTokenizer_Free(struct tok_state *tok)
{
if (tok->encoding != NULL)
- PyMem_FREE(tok->encoding);
+ PyMem_RAW_FREE(tok->encoding);
#ifndef PGEN
Py_XDECREF(tok->decoding_readline);
Py_XDECREF(tok->decoding_buffer);
#endif
if (tok->fp != NULL && tok->buf != NULL)
- PyMem_FREE(tok->buf);
- PyMem_FREE(tok);
+ PyMem_RAW_FREE(tok->buf);
+ PyMem_RAW_FREE(tok);
}
#if !defined(PGEN) && defined(Py_USING_UNICODE)
@@ -782,7 +782,7 @@
if (newtok == NULL)
tok->done = E_INTR;
else if (*newtok == '\0') {
- PyMem_FREE(newtok);
+ PyMem_RAW_FREE(newtok);
tok->done = E_EOF;
}
#if !defined(PGEN) && defined(Py_USING_UNICODE)
@@ -794,12 +794,12 @@
size_t oldlen = tok->cur - tok->buf;
size_t newlen = oldlen + strlen(newtok);
char *buf = tok->buf;
- buf = (char *)PyMem_REALLOC(buf, newlen+1);
+ buf = (char *)PyMem_RAW_REALLOC(buf, newlen+1);
tok->lineno++;
if (buf == NULL) {
- PyMem_FREE(tok->buf);
+ PyMem_RAW_FREE(tok->buf);
tok->buf = NULL;
- PyMem_FREE(newtok);
+ PyMem_RAW_FREE(newtok);
tok->done = E_NOMEM;
return EOF;
}
@@ -807,7 +807,7 @@
tok->cur = tok->buf + oldlen;
tok->line_start = tok->cur;
strcpy(tok->buf + oldlen, newtok);
- PyMem_FREE(newtok);
+ PyMem_RAW_FREE(newtok);
tok->inp = tok->buf + newlen;
tok->end = tok->inp + 1;
tok->start = tok->buf + start;
@@ -815,7 +815,7 @@
else {
tok->lineno++;
if (tok->buf != NULL)
- PyMem_FREE(tok->buf);
+ PyMem_RAW_FREE(tok->buf);
tok->buf = newtok;
tok->line_start = tok->buf;
tok->cur = tok->buf;
@@ -831,7 +831,7 @@
if (tok->start == NULL) {
if (tok->buf == NULL) {
tok->buf = (char *)
- PyMem_MALLOC(BUFSIZ);
+ PyMem_RAW_MALLOC(BUFSIZ);
if (tok->buf == NULL) {
tok->done = E_NOMEM;
return EOF;
@@ -866,7 +866,7 @@
Py_ssize_t curvalid = tok->inp - tok->buf;
Py_ssize_t newsize = curvalid + BUFSIZ;
char *newbuf = tok->buf;
- newbuf = (char *)PyMem_REALLOC(newbuf,
+ newbuf = (char *)PyMem_RAW_REALLOC(newbuf,
newsize);
if (newbuf == NULL) {
tok->done = E_NOMEM;
More information about the Python-checkins
mailing list