1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:17:35 +00:00

LibC: stdlib: Add clearenv() function

This commit is contained in:
Brendan Coles 2020-12-16 23:49:55 +00:00 committed by Andreas Kling
parent 3436317c08
commit 853664bd3c
4 changed files with 46 additions and 1 deletions

View file

@ -289,6 +289,16 @@ int unsetenv(const char* name)
return 0;
}
int clearenv()
{
size_t environ_size = 0;
for (; environ[environ_size]; ++environ_size) {
environ[environ_size] = NULL;
}
*environ = NULL;
return 0;
}
int setenv(const char* name, const char* value, int overwrite)
{
if (!overwrite && getenv(name))

View file

@ -47,6 +47,7 @@ __attribute__((alloc_size(2))) void* realloc(void* ptr, size_t);
char* getenv(const char* name);
int putenv(char*);
int unsetenv(const char*);
int clearenv(void);
int setenv(const char* name, const char* value, int overwrite);
int atoi(const char*);
long atol(const char*);