diff options
| author | Brian Somers <brian@FreeBSD.org> | 2000-09-20 19:46:03 +0000 |
|---|---|---|
| committer | Brian Somers <brian@FreeBSD.org> | 2000-09-20 19:46:03 +0000 |
| commit | 1a51451d83ffe3cc61a5b222352dbe78002077a5 (patch) | |
| tree | d64f8cb3d19e548ca3e3825fee6a1ebc8bd65246 | |
| parent | 994760debfa43dd03e96fe8d27c1b5cac3c4bcc2 (diff) | |
Notes
| -rw-r--r-- | lib/libc/stdlib/setenv.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c index 96f22a3e6ce5..cd82c0d87074 100644 --- a/lib/libc/stdlib/setenv.c +++ b/lib/libc/stdlib/setenv.c @@ -56,7 +56,7 @@ setenv(name, value, rewrite) int rewrite; { extern char **environ; - static int alloced; /* if allocated space before */ + static char **alloced; /* if allocated space before */ register char *c; int l_value, offset; @@ -75,21 +75,20 @@ setenv(name, value, rewrite) register char **p; for (p = environ, cnt = 0; *p; ++p, ++cnt); - if (alloced) { /* just increase size */ + if (alloced == environ) { /* just increase size */ p = (char **)realloc((char *)environ, (size_t)(sizeof(char *) * (cnt + 2))); if (!p) return (-1); - environ = p; + alloced = environ = p; } else { /* get new space */ /* copy old entries into it */ p = malloc((size_t)(sizeof(char *) * (cnt + 2))); if (!p) return (-1); - alloced = 1; bcopy(environ, p, cnt * sizeof(char *)); - environ = p; + alloced = environ = p; } environ[cnt + 1] = NULL; offset = cnt; |
