]> git.saurik.com Git - apple/libc.git/blob - stdlib/FreeBSD/getenv.c.patch
Libc-594.9.1.tar.gz
[apple/libc.git] / stdlib / FreeBSD / getenv.c.patch
1 --- getenv.c.orig 2006-08-29 00:12:28.000000000 -0700
2 +++ getenv.c 2006-08-29 00:13:31.000000000 -0700
3 @@ -40,8 +40,9 @@
4 #include <stdlib.h>
5 #include <stddef.h>
6 #include <string.h>
7 +#include <crt_externs.h>
8
9 -inline char *__findenv(const char *, int *);
10 +__private_extern__ char *__findenv(const char *, int *, char **);
11
12 /*
13 * __findenv --
14 @@ -52,12 +53,12 @@
15 *
16 * This routine *should* be a static; don't use it.
17 */
18 -inline char *
19 -__findenv(name, offset)
20 +__private_extern__ char *
21 +__findenv(name, offset, environ)
22 const char *name;
23 int *offset;
24 + char **environ;
25 {
26 - extern char **environ;
27 int len, i;
28 const char *np;
29 char **p, *cp;
30 @@ -80,6 +81,19 @@
31 }
32
33 /*
34 + * _getenvp -- SPI using an arbitrary pointer to string array (the array must
35 + * have been created with malloc) and an env state, created by _allocenvstate().
36 + * Returns ptr to value associated with name, if any, else NULL.
37 + */
38 +char *
39 +_getenvp(const char *name, char ***envp, void *state __unused)
40 +{
41 + int offset;
42 +
43 + return (__findenv(name, &offset, *envp));
44 +}
45 +
46 +/*
47 * getenv --
48 * Returns ptr to value associated with name, if any, else NULL.
49 */
50 @@ -89,5 +103,5 @@
51 {
52 int offset;
53
54 - return (__findenv(name, &offset));
55 + return (__findenv(name, &offset, *_NSGetEnviron()));
56 }