reduce spurious inclusion of libc.h
[musl] / src / env / getenv.c
1 #include <stdlib.h>
2 #include <string.h>
3 #include <unistd.h>
4
5 char *getenv(const char *name)
6 {
7         size_t l = __strchrnul(name, '=') - name;
8         if (l && !name[l] && __environ)
9                 for (char **e = __environ; *e; e++)
10                         if (!strncmp(name, *e, l) && l[*e] == '=')
11                                 return *e + l+1;
12         return 0;
13 }