use SetEnvironmentVariableA to set env var on windows
authorXiao Xiangquan <xiaoxiangquan@gmail.com>
Sun, 4 Sep 2011 14:32:32 +0000 (14:32 +0000)
committerXiao Xiangquan <xiaoxiangquan@gmail.com>
Sun, 4 Sep 2011 14:32:32 +0000 (14:32 +0000)
CMakeLists.txt
source/blender/blenlib/intern/path_util.c

index 38ce868..5e40f8d 100644 (file)
@@ -565,6 +565,8 @@ elseif(WIN32)
                set(ICONV_INCLUDE_DIRS ${ICONV}/include)
                set(ICONV_LIBRARIES iconv)
                set(ICONV_LIBPATH ${ICONV}/lib)
+               set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MD")
+               set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MD")
        endif()
 
        if(WITH_SAMPLERATE)
index f892831..35e28b5 100644 (file)
@@ -72,6 +72,7 @@
 #endif
 #define _WIN32_IE 0x0501
 #include <windows.h>
+#include <Winbase.h>
 #include <shlobj.h>
 
 #include "BLI_winstuff.h"
@@ -1157,14 +1158,13 @@ void BLI_setenv(const char *env, const char*val)
 {
        /* SGI or free windows */
 #if (defined(__sgi) || ((defined(WIN32) || defined(WIN64)) && defined(FREE_WINDOWS)))
-       char *envstr= MEM_mallocN(sizeof(char) * (strlen(env) + strlen(val) + 2), "envstr"); /* one for = another for \0 */
-
-       sprintf(envstr, "%s=%s", env, val);
+       char *envstr= BLI_sprintfN("%s=%s", env, val);
        putenv(envstr);
        MEM_freeN(envstr);
 
        /* non-free windows */
 #elif (defined(WIN32) || defined(WIN64)) /* not free windows */
+       SetEnvironmentVariableA(env, val);
        _putenv_s(env, val);
 #else
        /* linux/osx/bsd */