Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: fusl/src/env/unsetenv.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/env/setenv.c ('k') | fusl/src/errno/__errno_location.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <stdlib.h>
2 #include <string.h>
3 #include <errno.h>
4
5 extern char **__environ;
6 extern char **__env_map;
7
8 int unsetenv(const char *name)
9 {
10 int i, j;
11 size_t l = strlen(name);
12
13 if (!*name || strchr(name, '=')) {
14 errno = EINVAL;
15 return -1;
16 }
17 again:
18 for (i=0; __environ[i] && (memcmp(name, __environ[i], l) || __environ[i] [l] != '='); i++);
19 if (__environ[i]) {
20 if (__env_map) {
21 for (j=0; __env_map[j] && __env_map[j] != __environ[i]; j++);
22 free (__env_map[j]);
23 for (; __env_map[j]; j++)
24 __env_map[j] = __env_map[j+1];
25 }
26 for (; __environ[i]; i++)
27 __environ[i] = __environ[i+1];
28 goto again;
29 }
30 return 0;
31 }
OLDNEW
« no previous file with comments | « fusl/src/env/setenv.c ('k') | fusl/src/errno/__errno_location.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698