summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/setenv.c
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2007-04-30 16:56:18 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2007-04-30 16:56:18 +0000
commit15fdb055e5a9a944685cf8bcf94e5858589a6740 (patch)
tree0f48274fab3bf61e5379abd241da2f704d7da652 /lib/libc/stdlib/setenv.c
parent0f23397d3f48d318ba3ad10e8d9e2cdb55657c7e (diff)
Notes
Diffstat (limited to 'lib/libc/stdlib/setenv.c')
-rw-r--r--lib/libc/stdlib/setenv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c
index 2695af77b625..5725733b5066 100644
--- a/lib/libc/stdlib/setenv.c
+++ b/lib/libc/stdlib/setenv.c
@@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
+char **__alloced; /* if allocated space before */
+
char *__findenv(const char *, int *);
/*
@@ -52,7 +54,6 @@ setenv(name, value, rewrite)
int rewrite;
{
extern char **environ;
- static char **alloced; /* if allocated space before */
char *c;
int l_value, offset;
@@ -74,26 +75,25 @@ setenv(name, value, rewrite)
char **p;
for (p = environ, cnt = 0; *p; ++p, ++cnt);
- if (alloced == environ) { /* just increase size */
+ if (__alloced == environ) { /* just increase size */
p = (char **)realloc((char *)environ,
(size_t)(sizeof(char *) * (cnt + 2)));
if (!p)
return (-1);
- alloced = environ = p;
}
else { /* get new space */
/* copy old entries into it */
- p = malloc((size_t)(sizeof(char *) * (cnt + 2)));
+ p = (char **)malloc((size_t)(sizeof(char *) * (cnt + 2)));
if (!p)
return (-1);
bcopy(environ, p, cnt * sizeof(char *));
- alloced = environ = p;
}
+ __alloced = environ = p;
environ[cnt + 1] = NULL;
offset = cnt;
}
if (!(environ[offset] = /* name + `=' + value */
- malloc((size_t)(strlen(name) + l_value + 2))))
+ (char *)malloc((size_t)(strlen(name) + l_value + 2))))
return (-1);
for (c = environ[offset]; (*c = *name++) && *c != '='; ++c);
for (*c++ = '='; (*c++ = *value++); );