ruby-changes:43744
From: nobu <ko1@a...>
Date: Fri, 5 Aug 2016 17:31:28 +0900 (JST)
Subject: [ruby-changes:43744] nobu:r55817 (trunk): win32.c: initialize with an impossible value
nobu 2016-08-05 17:31:23 +0900 (Fri, 05 Aug 2016) New Revision: 55817 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55817 Log: win32.c: initialize with an impossible value * win32/win32.c (getifaddrs, rb_w32_getppid): initialize the API pointers with an impossible value not to try everytime on old platforms. Modified files: trunk/win32/win32.c Index: win32/win32.c =================================================================== --- win32/win32.c (revision 55816) +++ win32/win32.c (revision 55817) @@ -4034,8 +4034,8 @@ str2guid(const char *str, GUID *guid) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4034 #endif typedef DWORD (WINAPI *cigl_t)(const GUID *, NET_LUID *); typedef DWORD (WINAPI *cilnA_t)(const NET_LUID *, char *, size_t); -static cigl_t pConvertInterfaceGuidToLuid = NULL; -static cilnA_t pConvertInterfaceLuidToNameA = NULL; +static cigl_t pConvertInterfaceGuidToLuid = (cigl_t)-1; +static cilnA_t pConvertInterfaceLuidToNameA = (cilnA_t)-1; int getifaddrs(struct ifaddrs **ifap) @@ -4058,11 +4058,11 @@ getifaddrs(struct ifaddrs **ifap) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L4058 return -1; } - if (!pConvertInterfaceGuidToLuid) + if (pConvertInterfaceGuidToLuid == (cigl_t)-1) pConvertInterfaceGuidToLuid = (cigl_t)get_proc_address("iphlpapi.dll", "ConvertInterfaceGuidToLuid", NULL); - if (!pConvertInterfaceLuidToNameA) + if (pConvertInterfaceLuidToNameA == (cilnA_t)-1) pConvertInterfaceLuidToNameA = (cilnA_t)get_proc_address("iphlpapi.dll", "ConvertInterfaceLuidToNameA", NULL); @@ -5995,10 +5995,10 @@ rb_pid_t https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L5995 rb_w32_getppid(void) { typedef long (WINAPI query_func)(HANDLE, int, void *, ULONG, ULONG *); - static query_func *pNtQueryInformationProcess = NULL; + static query_func *pNtQueryInformationProcess = (query_func *)-1; rb_pid_t ppid = 0; - if (!pNtQueryInformationProcess) + if (pNtQueryInformationProcess == (query_func *)-1) pNtQueryInformationProcess = (query_func *)get_proc_address("ntdll.dll", "NtQueryInformationProcess", NULL); if (pNtQueryInformationProcess) { struct { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/