1 --- putenv.c.orig 2006-10-05 11:57:06.000000000 -0700
2 +++ putenv.c 2006-11-02 11:15:33.000000000 -0800
7 +#include <sys/types.h>
9 +#include <crt_externs.h>
10 +#include <malloc/malloc.h>
13 +extern malloc_zone_t *__zone0;
14 +extern void __malloc_check_env_name(const char *);
16 +__private_extern__ int __setenv(const char *, const char *, int, int, char ***, malloc_zone_t *);
18 +#ifndef BUILDING_VARIANT
20 + * _putenvp -- SPI using an arbitrary pointer to string array (the array must
21 + * have been created with malloc) and an env state, created by _allocenvstate().
22 + * Returns ptr to value associated with name, if any, else NULL.
27 +_putenvp(char *str, char ***envp, void *state)
31 + /* insure __zone0 is set up */
33 + __zone0 = malloc_create_zone(0, 0);
39 + return (__setenv(str, NULL, 1, 0, envp, (state ? (malloc_zone_t *)state : __zone0)));
41 +#endif /* BUILDING_VARIANT */
43 - if ((p = strdup(str)) == NULL)
49 + if (str == NULL || *str == 0 || index(str, '=') == NULL) {
52 - if ((equal = index(p, '=')) == NULL) {
55 +#else /* !__DARWIN_UNIX03 */
56 + if (index(str, '=') == NULL)
58 +#endif /* __DARWIN_UNIX03 */
59 + /* insure __zone0 is set up before calling __malloc_check_env_name */
61 + __zone0 = malloc_create_zone(0, 0);
68 - rval = setenv(p, equal + 1, 1);
71 + __malloc_check_env_name(str); /* see if we are changing a malloc environment variable */
72 + return (__setenv(str, NULL, 1,
75 +#else /* !__DARWIN_UNIX03 */
77 +#endif /* __DARWIN_UNIX03 */
78 + _NSGetEnviron(), __zone0));