svn commit: samba r21797 - in
branches/SAMBA_4_0/source/lib/replace: .
metze at samba.org
metze at samba.org
Mon Mar 12 11:32:19 GMT 2007
Author: metze
Date: 2007-03-12 11:32:19 +0000 (Mon, 12 Mar 2007)
New Revision: 21797
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21797
Log:
remove the key directly from the environ array
inspired by:
http://cvs.linux-ha.org/viewcvs/viewcvs.cgi/linux-ha/replace/unsetenv.c?rev=1.4&view=auto
metze
Modified:
branches/SAMBA_4_0/source/lib/replace/replace.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/replace.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.c 2007-03-12 11:31:06 UTC (rev 21796)
+++ branches/SAMBA_4_0/source/lib/replace/replace.c 2007-03-12 11:32:19 UTC (rev 21797)
@@ -593,34 +593,26 @@
#ifndef HAVE_UNSETENV
int rep_unsetenv(const char *name)
{
- char *p;
- size_t l1;
- int ret;
+ extern char **environ;
+ size_t len = strlen(name);
+ size_t i;
+ int found = 0;
- if (!getenv(name)) {
- return 0;
- }
+ for (i=0; (environ && environ[i]); i++) {
+ if (found) {
+ environ[i-1] = environ[i];
+ continue;
+ }
- l1 = strlen(name);
-
- p = malloc(l1+1);
- if (p == NULL) {
- return -1;
+ if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') {
+ free(environ[i]);
+ environ[i] = NULL;
+ found = 1;
+ continue;
+ }
}
- memcpy(p, name, l1);
- p[l1] = 0;
- /*
- * use using "name" here unsets the var
- *
- * "name=" would set it to an empty string..
- */
- ret = putenv(p);
- if (ret != 0) {
- free(p);
- }
-
- return ret;
+ return 0;
}
#endif
More information about the samba-cvs
mailing list