1 #include <stdlib.h>
2 #include <string.h>
4 void gitunsetenv (const char *name)
5 {
6 extern char **environ;
7 int src, dst;
8 size_t nmln;
10 nmln = strlen(name);
12 for (src = dst = 0; environ[src]; ++src) {
13 size_t enln;
14 enln = strlen(environ[src]);
15 if (enln > nmln) {
16 /* might match, and can test for '=' safely */
17 if (0 == strncmp (environ[src], name, nmln)
18 && '=' == environ[src][nmln])
19 /* matches, so skip */
20 continue;
21 }
22 environ[dst] = environ[src];
23 ++dst;
24 }
25 environ[dst] = NULL;
26 }