2 * (c) copyright 1989 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: putenv.c,v 1.6 1994/06/24 11:45:38 ceriel Exp $ */
11 #define rounded(x) (((x / ENTRY_INC) + 1) * ENTRY_INC)
13 extern const char **_penvp;
14 extern const char **environ; /* environ is a shadow name for _penvp */
19 register const char **v = _penvp;
22 /* When size != 0, it contains the number of entries in the
23 * table (including the final NULL pointer). This means that the
24 * last non-null entry is _penvp[size - 2].
28 if (r = strchr(name, '=')) {
29 register const char *p, *q;
34 while ((p = *v) != NULL) {
36 while (*q && (*q++ == *p++))
38 if (*q || (*p != '=')) {
41 /* The name was already in the
55 register const char **p;
62 if (!(v = malloc(rounded(i) * sizeof(char **))))
67 while (*v++ = *p++); /* copy the environment */
69 } else if (!(size % ENTRY_INC)) {
70 if (!(v = realloc(_penvp, rounded(size) * sizeof(char **))))