summaryrefslogtreecommitdiffstats
path: root/Modules/config.c.in
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-10-05 12:25:12 (GMT)
committerGuido van Rossum <guido@python.org>1994-10-05 12:25:12 (GMT)
commit6e890b86a87b36b148d802b03e0ab55d471cfd74 (patch)
tree6763c290b090ccf6d3854552608d17ffbda5ead4 /Modules/config.c.in
parenta44031031c4b95ee45c2cf874a42e80372690214 (diff)
downloadcpython-6e890b86a87b36b148d802b03e0ab55d471cfd74.zip
cpython-6e890b86a87b36b148d802b03e0ab55d471cfd74.tar.gz
cpython-6e890b86a87b36b148d802b03e0ab55d471cfd74.tar.bz2
Save static pointer to malloc'ed buffer
Diffstat (limited to 'Modules/config.c.in')
-rw-r--r--Modules/config.c.in16
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/config.c.in b/Modules/config.c.in
index 7843f14..981a19f 100644
--- a/Modules/config.c.in
+++ b/Modules/config.c.in
@@ -149,27 +149,27 @@ extern char *getenv();
char *
getpythonpath()
{
-#ifdef macintosh
- return PYTHONPATH;
-#else /* !macintosh */
char *path = getenv("PYTHONPATH");
char *defpath = PYTHONPATH;
- char *buf;
+ static char *buf = NULL;
char *p;
int n;
- if (path == 0 || *path == '\0')
- return defpath;
+ if (path == NULL)
+ path = "";
n = strlen(path) + strlen(defpath) + 2;
+ if (buf != NULL) {
+ free(buf);
+ buf = NULL;
+ }
buf = malloc(n);
if (buf == NULL)
- return path; /* XXX too bad -- but not likely */
+ fatal("not enough memory to copy module search path");
strcpy(buf, path);
p = buf + strlen(buf);
*p++ = DELIM;
strcpy(p, defpath);
return buf;
-#endif /* !macintosh */
}