summaryrefslogtreecommitdiffstats
path: root/Parser/myreadline.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-04-11 08:19:15 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-04-11 08:19:15 (GMT)
commit08062d6665b6a0c30559eb8a064356ca86151caf (patch)
treebd3aefcf6dd68268466453621dfd6c6b74b090bb /Parser/myreadline.c
parent01b810106c348db2e3242126adf655b686aa2a1c (diff)
downloadcpython-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/myreadline.c')
-rw-r--r--Parser/myreadline.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 7b27ea2..32a1088 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -111,7 +111,7 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
size_t n;
char *p;
n = 100;
- if ((p = (char *)PyObject_MALLOC(n)) == NULL)
+ if ((p = (char *)PyMem_MALLOC(n)) == NULL)
return NULL;
fflush(sys_stdout);
#ifndef RISCOS
@@ -130,7 +130,7 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
case 0: /* Normal case */
break;
case 1: /* Interrupt */
- PyObject_FREE(p);
+ PyMem_FREE(p);
return NULL;
case -1: /* EOF */
case -2: /* Error */
@@ -141,7 +141,7 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
n = strlen(p);
while (n > 0 && p[n-1] != '\n') {
size_t incr = n+2;
- p = (char *)PyObject_REALLOC(p, n + incr);
+ p = (char *)PyMem_REALLOC(p, n + incr);
if (p == NULL)
return NULL;
if (incr > INT_MAX) {
@@ -151,14 +151,14 @@ PyOS_StdioReadline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
break;
n += strlen(p+n);
}
- return (char *)PyObject_REALLOC(p, n+1);
+ return (char *)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 PyObject_Malloc. */
+ Note: Python expects in return a buffer allocated with PyMem_Malloc. */
char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);