Skip to content

Commit 4137c48

Browse files
cfriedtnashif
authored andcommitted
posix: env: create z_getenv()..z_setenv() convenience functions
To facilitate adding putenv in a separate compilation unit, make z_getenv(), z_getenv_r(), z_setenv(), and z_unsetenv() convenience functions. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
1 parent ebfc7db commit 4137c48

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

lib/posix/options/env.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static int findenv(const char *name, size_t namelen)
6464
return -ENOENT;
6565
}
6666

67-
char *getenv(const char *name)
67+
char *z_getenv(const char *name)
6868
{
6969
int ret;
7070
size_t nsize;
@@ -83,8 +83,12 @@ char *getenv(const char *name)
8383

8484
return val;
8585
}
86+
char *getenv(const char *name)
87+
{
88+
return z_getenv(name);
89+
}
8690

87-
int getenv_r(const char *name, char *buf, size_t len)
91+
int z_getenv_r(const char *name, char *buf, size_t len)
8892
{
8993
int ret = 0;
9094
size_t vsize;
@@ -117,8 +121,12 @@ int getenv_r(const char *name, char *buf, size_t len)
117121

118122
return ret;
119123
}
124+
int getenv_r(const char *name, char *buf, size_t len)
125+
{
126+
return z_getenv_r(name, buf, len);
127+
}
120128

121-
int setenv(const char *name, const char *val, int overwrite)
129+
int z_setenv(const char *name, const char *val, int overwrite)
122130
{
123131
int ret = 0;
124132
char *env;
@@ -203,8 +211,12 @@ int setenv(const char *name, const char *val, int overwrite)
203211

204212
return ret;
205213
}
214+
int setenv(const char *name, const char *val, int overwrite)
215+
{
216+
return z_setenv(name, val, overwrite);
217+
}
206218

207-
int unsetenv(const char *name)
219+
int z_unsetenv(const char *name)
208220
{
209221
int ret = 0;
210222
char **envp;
@@ -265,3 +277,7 @@ int unsetenv(const char *name)
265277

266278
return ret;
267279
}
280+
int unsetenv(const char *name)
281+
{
282+
return z_unsetenv(name);
283+
}

0 commit comments

Comments
 (0)