cp = strdup(envstr); if (cp == NULL) return(NULL);
}
env_set(char **envp, char *envstr) {	int count, found;	char **p, *cp;	/*	 * count the number of elements, including the null pointer;	 * also set 'found' to -1 or index of entry if already in here.	 */	found = -1;	for (count = 0;  envp[count] != NULL;  count++) {		if (!strcmp_until(envp[count], envstr, '='))			found = count;	}	count++;	/* for the NULL */	if (found != -1) {		/*		 * it exists already, so just free the existing setting,		 * save our new one there, and return the existing array.		 */		free(envp[found]);		if ((envp[found] = strdup(envstr)) == NULL) {			envp[found] = "";			return (NULL);		}		return (envp);	}	/*	 * it doesn't exist yet, so resize the array, move null pointer over	 * one, save our string over the old null pointer, and return resized	 * array.	 */	p = (char **) realloc((void *) envp,			      (size_t) ((count+1) * sizeof(char **)));	if (p == NULL)		return (NULL);	cp = strdup(envstr);	if (cp == NULL)		return(NULL);	p[count] = p[count-1];	p[count-1] = cp;	return (p);}