if (i >= (*envsizep) - 1) { if (*envsizep >= 1000) fatal("child_set_env: too many env vars," " skipping: %.100s", name); (*envsizep) += 50; env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *));
envsize = *envsizep; if (i >= envsize - 1) { if (envsize >= 1000) fatal("child_set_env: too many env vars"); envsize += 50; env = (*envp) = xrealloc(env, envsize * sizeof(char *)); *envsizep = envsize;
child_set_env(char ***envp, u_int *envsizep, const char *name,	const char *value){	u_int i, namelen;	char **env;	/*	 * Find the slot where the value should be stored.  If the variable	 * already exists, we reuse the slot; otherwise we append a new slot	 * at the end of the array, expanding if necessary.	 */	env = *envp;	namelen = strlen(name);	for (i = 0; env[i]; i++)		if (strncmp(env[i], name, namelen) == 0 && env[i][namelen] == '=')			break;	if (env[i]) {		/* Reuse the slot. */		xfree(env[i]);	} else {		/* New variable.  Expand if necessary. */		if (i >= (*envsizep) - 1) {			if (*envsizep >= 1000)				fatal("child_set_env: too many env vars,"				    " skipping: %.100s", name);			(*envsizep) += 50;			env = (*envp) = xrealloc(env, (*envsizep) * sizeof(char *));		}		/* Need to set the NULL pointer at end of array beyond the new slot. */		env[i + 1] = NULL;	}	/* Allocate space and format the variable in the appropriate slot. */	env[i] = xmalloc(strlen(name) + 1 + strlen(value) + 1);	snprintf(env[i], strlen(name) + 1 + strlen(value) + 1, "%s=%s", name, value);}