]> git.saurik.com Git - apple/libc.git/blob - stdlib/FreeBSD/getenv.c.patch
2155a0b6df26a6c6ec5bbe87f54c00cca91efa14
[apple/libc.git] / stdlib / FreeBSD / getenv.c.patch
1 --- getenv.c.bsdnew 2009-11-13 15:14:36.000000000 -0800
2 +++ getenv.c 2009-11-13 15:14:50.000000000 -0800
3 @@ -36,8 +36,9 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/
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 @@ -48,12 +49,12 @@ inline char *__findenv(const char *, int
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 @@ -76,6 +77,19 @@ __findenv(name, offset)
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 @@ -85,5 +99,5 @@ getenv(name)
51 {
52 int offset;
53
54 - return (__findenv(name, &offset));
55 + return (__findenv(name, &offset, *_NSGetEnviron()));
56 }