https://github.com/git/git
Raw File
Tip revision: d9f5ef7a4a760d58f1f824f9fb8c12ef0371d3a9 authored by Junio C Hamano on 26 April 2012, 16:59:22 UTC
Git 1.7.8.6
Tip revision: d9f5ef7
unsetenv.c
#include "../git-compat-util.h"

void gitunsetenv (const char *name)
{
     extern char **environ;
     int src, dst;
     size_t nmln;

     nmln = strlen(name);

     for (src = dst = 0; environ[src]; ++src) {
	  size_t enln;
	  enln = strlen(environ[src]);
	  if (enln > nmln) {
               /* might match, and can test for '=' safely */
	       if (0 == strncmp (environ[src], name, nmln)
		   && '=' == environ[src][nmln])
		    /* matches, so skip */
		    continue;
	  }
	  environ[dst] = environ[src];
	  ++dst;
     }
     environ[dst] = NULL;
}
back to top