]> git.proxmox.com Git - wasi-libc.git/blame - libc-top-half/musl/src/env/clearenv.c
Lazy-initialize the environment variables. (#184)
[wasi-libc.git] / libc-top-half / musl / src / env / clearenv.c
CommitLineData
320054e8
DG
1#define _GNU_SOURCE
2#include <stdlib.h>
3#include <unistd.h>
4
5static void dummy(char *old, char *new) {}
6weak_alias(dummy, __env_rm_add);
7
8int clearenv()
9{
9efc2f42
DG
10#ifdef __wasilibc_unmodified_upstream // Lazy environment variable init.
11#else
12// This specialized header is included within the function body to arranges for
13// the environment variables to be lazily initialized. It redefined `__environ`,
14// so don't remove or reorder it with respect to other code.
15#include "wasi/libc-environ-compat.h"
16#endif
320054e8
DG
17 char **e = __environ;
18 __environ = 0;
19 if (e) while (*e) __env_rm_add(*e++, 0);
20 return 0;
21}