1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-16 00:23:52 +03:00

r21793: add replacement for unsetenv()

metze
(This used to be commit d6de7f2cda)
This commit is contained in:
Stefan Metzmacher
2007-03-12 09:59:06 +00:00
committed by Gerald (Jerry) Carter
parent 9b921af12e
commit 544a2d30e0
4 changed files with 42 additions and 1 deletions

View File

@@ -590,6 +590,40 @@ int rep_setenv(const char *name, const char *value, int overwrite)
}
#endif
#ifndef HAVE_UNSETENV
int rep_unsetenv(const char *name)
{
char *p;
size_t l1;
int ret;
if (!getenv(name)) {
return 0;
}
l1 = strlen(name);
p = malloc(l1+1);
if (p == NULL) {
return -1;
}
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;
}
#endif
#ifndef HAVE_SOCKETPAIR
int rep_socketpair(int d, int type, int protocol, int sv[2])
{