From d74e778d8abbfea244bacbeb352cadc737032e85 Mon Sep 17 00:00:00 2001 From: Christian Ullrich Date: Tue, 26 Apr 2016 15:26:14 +0200 Subject: [PATCH 1/3] Cleanups in pgwin32_putenv(). - Added UCRT and all debug CRTs - Condensed the array to one line per item (it was getting long) - Test HMODULEs for NULL instead of zero - Removed unnecessary CloseHandle() call --- src/port/win32env.c | 49 ++++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/src/port/win32env.c b/src/port/win32env.c index 7e4ff62..fd6762e 100644 --- a/src/port/win32env.c +++ b/src/port/win32env.c @@ -45,33 +45,25 @@ pgwin32_putenv(const char *envval) PUTENVPROC putenvFunc; } rtmodules[] = { - { - "msvcrt", 0, NULL - }, /* Visual Studio 6.0 / mingw */ - { - "msvcr70", 0, NULL - }, /* Visual Studio 2002 */ - { - "msvcr71", 0, NULL - }, /* Visual Studio 2003 */ - { - "msvcr80", 0, NULL - }, /* Visual Studio 2005 */ - { - "msvcr90", 0, NULL - }, /* Visual Studio 2008 */ - { - "msvcr100", 0, NULL - }, /* Visual Studio 2010 */ - { - "msvcr110", 0, NULL - }, /* Visual Studio 2012 */ - { - "msvcr120", 0, NULL - }, /* Visual Studio 2013 */ - { - NULL, 0, NULL - } + { "msvcrt", NULL, NULL }, + { "msvcrtd", NULL, NULL }, /* Visual Studio 6.0 / mingw */ + { "msvcr70", NULL, NULL }, + { "msvcr70d", NULL, NULL }, /* Visual Studio 2002 */ + { "msvcr71", NULL, NULL }, + { "msvcr71d", NULL, NULL }, /* Visual Studio 2003 */ + { "msvcr80", NULL, NULL }, + { "msvcr80d", NULL, NULL }, /* Visual Studio 2005 */ + { "msvcr90", NULL, NULL }, + { "msvcr90d", NULL, NULL }, /* Visual Studio 2008 */ + { "msvcr100", NULL, NULL }, + { "msvcr100d", NULL, NULL }, /* Visual Studio 2010 */ + { "msvcr110", NULL, NULL }, + { "msvcr110d", NULL, NULL }, /* Visual Studio 2012 */ + { "msvcr120", NULL, NULL }, + { "msvcr120d", NULL, NULL }, /* Visual Studio 2013 */ + { "ucrtbase", NULL, NULL }, + { "ucrtbased", NULL, NULL }, /* Visual Studio 2015+ */ + { NULL, 0, NULL } }; int i; @@ -79,7 +71,7 @@ pgwin32_putenv(const char *envval) { if (rtmodules[i].putenvFunc == NULL) { - if (rtmodules[i].hmodule == 0) + if (rtmodules[i].hmodule == NULL) { /* Not attempted before, so try to find this DLL */ rtmodules[i].hmodule = GetModuleHandle(rtmodules[i].modulename); @@ -97,7 +89,6 @@ pgwin32_putenv(const char *envval) rtmodules[i].putenvFunc = (PUTENVPROC) GetProcAddress(rtmodules[i].hmodule, "_putenv"); if (rtmodules[i].putenvFunc == NULL) { - CloseHandle(rtmodules[i].hmodule); rtmodules[i].hmodule = INVALID_HANDLE_VALUE; continue; } -- 2.8.1.windows.1