diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-04-11 08:19:15 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-04-11 08:19:15 (GMT) |
commit | 08062d6665b6a0c30559eb8a064356ca86151caf (patch) | |
tree | bd3aefcf6dd68268466453621dfd6c6b74b090bb /Parser/pgenmain.c | |
parent | 01b810106c348db2e3242126adf655b686aa2a1c (diff) | |
download | cpython-08062d6665b6a0c30559eb8a064356ca86151caf.zip cpython-08062d6665b6a0c30559eb8a064356ca86151caf.tar.gz cpython-08062d6665b6a0c30559eb8a064356ca86151caf.tar.bz2 |
As discussed on python-dev, really fix the PyMem_*/PyObject_* memory API
mismatches. At least I hope this fixes them all.
This reverts part of my change from yesterday that converted everything
in Parser/*.c to use PyObject_* API. The encoding doesn't really need
to use PyMem_*, however, it uses new_string() which must return PyMem_*
for handling the result of PyOS_Readline() which returns PyMem_* memory.
If there were 2 versions of new_string() one that returned PyMem_*
for tokens and one that return PyObject_* for encodings that could
also fix this problem. I'm not sure which version would be clearer.
This seems to fix both Guido's and Phillip's problems, so it's good enough
for now. After this change, it would be good to review Parser/*.c
for consistent use of the 2 memory APIs.
Diffstat (limited to 'Parser/pgenmain.c')
-rw-r--r-- | Parser/pgenmain.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c index 6d8469f..6e22e37 100644 --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -136,7 +136,7 @@ char * PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) { size_t n = 1000; - char *p = PyObject_MALLOC(n); + char *p = PyMem_MALLOC(n); char *q; if (p == NULL) return NULL; @@ -149,7 +149,7 @@ PyOS_Readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt) n = strlen(p); if (n > 0 && p[n-1] != '\n') p[n-1] = '\n'; - return PyObject_REALLOC(p, n+1); + return PyMem_REALLOC(p, n+1); } /* No-nonsense fgets */ |