X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=lib%2Fmsvcrt%2Fstdlib%2Fputenv.c;h=3f5c3de00d8195c3ea4778907e5333bfbd3ce613;hp=ce68245ba8743cff33d809316c89dc81ac9beb31;hb=03af8776dc14167b078911b0c7c5327d1bcdd128;hpb=f4077c1bf64ef89d74a8d4822d2d7aada3ba9927 diff --git a/lib/msvcrt/stdlib/putenv.c b/lib/msvcrt/stdlib/putenv.c index ce68245..3f5c3de 100644 --- a/lib/msvcrt/stdlib/putenv.c +++ b/lib/msvcrt/stdlib/putenv.c @@ -8,44 +8,24 @@ extern int BlockEnvToEnviron(); // defined in misc/dllmain.c -int _putenv(const char *val) +int _putenv(const char* val) { - char *buffer; - char *epos; - int res; + char* buffer; + char* epos; + int res; - DPRINT("_putenv('%s')\n", val); - epos = strchr(val, '='); - if ( epos == NULL ) - return -1; - buffer = (char*)malloc(epos - val + 1); - if (buffer == NULL) - return -1; - strncpy(buffer, val, epos - val); - buffer[epos - val] = 0; - res = SetEnvironmentVariableA(buffer,epos+1); - free(buffer); - if (BlockEnvToEnviron()) return 0; - return res; -} - -int _wputenv(const wchar_t *val) -{ - wchar_t *buffer; - wchar_t *epos; - int res; - - DPRINT("_wputenv('%S')\n", val); - epos = wcsrchr(val, L'='); - if ( epos == NULL ) - return -1; - buffer = (char*)malloc((epos - val + 1) * sizeof (wchar_t)); - if (buffer == NULL) - return -1; - wcsncpy(buffer, val, epos - val); - buffer[epos - val] = 0; - res = SetEnvironmentVariableW(buffer,epos+1); - free(buffer); - if (BlockEnvToEnviron() ) return 0; - return res; + DPRINT("_putenv('%s')\n", val); + epos = strchr(val, '='); + if ( epos == NULL ) + return -1; + buffer = (char*)malloc(epos - val + 1); + if (buffer == NULL) + return -1; + strncpy(buffer, val, epos - val); + buffer[epos - val] = 0; + res = SetEnvironmentVariableA(buffer, epos+1); + free(buffer); + if (BlockEnvToEnviron()) + return 0; + return res; }