version 1.163, 2003/08/31 13:29:05 |
version 1.164, 2003/09/18 08:49:45 |
|
|
child_set_env(char ***envp, u_int *envsizep, const char *name, |
child_set_env(char ***envp, u_int *envsizep, const char *name, |
const char *value) |
const char *value) |
{ |
{ |
u_int i, namelen; |
|
char **env; |
char **env; |
|
u_int envsize; |
|
u_int i, namelen; |
|
|
/* |
/* |
* Find the slot where the value should be stored. If the variable |
* Find the slot where the value should be stored. If the variable |
|
|
xfree(env[i]); |
xfree(env[i]); |
} else { |
} else { |
/* New variable. Expand if necessary. */ |
/* New variable. Expand if necessary. */ |
if (i >= (*envsizep) - 1) { |
envsize = *envsizep; |
if (*envsizep >= 1000) |
if (i >= envsize - 1) { |
fatal("child_set_env: too many env vars," |
if (envsize >= 1000) |
" skipping: %.100s", name); |
fatal("child_set_env: too many env vars"); |
(*envsizep) += 50; |
envsize += 50; |
env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *)); |
env = (*envp) = xrealloc(env, envsize * sizeof(char *)); |
|
*envsizep = envsize; |
} |
} |
/* Need to set the NULL pointer at end of array beyond the new slot. */ |
/* Need to set the NULL pointer at end of array beyond the new slot. */ |
env[i + 1] = NULL; |
env[i + 1] = NULL; |