diff options
Diffstat (limited to 'mdk-stage1/dietlibc/lib/putenv.c')
-rw-r--r-- | mdk-stage1/dietlibc/lib/putenv.c | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/mdk-stage1/dietlibc/lib/putenv.c b/mdk-stage1/dietlibc/lib/putenv.c deleted file mode 100644 index 274b16b0e..000000000 --- a/mdk-stage1/dietlibc/lib/putenv.c +++ /dev/null @@ -1,37 +0,0 @@ -#include <stdlib.h> -#include <string.h> - -int putenv(const char *string) { - int len; - int envc; - char *tmp; - const char **ep; - char **newenv; - static char **origenv=0; - if (!origenv) origenv=environ; - if (!(tmp=strchr(string,'='))) - len=strlen(string); - else - len=tmp-string+1; - for (envc=0, ep=(const char**)environ; *ep; ++ep) { - if (!memcmp(string,*ep,len)) { /* found */ - if (!tmp) { - for (; ep[1]; ++ep) ep[0]=ep[1]; - ep[0]=0; - return 0; - } - *ep=string; - return 0; - } - ++envc; - } - if (tmp) { - newenv=(char**)malloc((envc+2)*sizeof(char*)); - if (!newenv) return -1; - newenv[0]=(char*)string; - memcpy(newenv+1,environ,(envc+1)*sizeof(char*)); - if (environ!=origenv) free(environ); - environ=newenv; - } - return 0; -} |