[前][次][番号順一覧][スレッド一覧]

ruby-changes:43743

From: nobu <ko1@a...>
Date: Fri, 5 Aug 2016 17:28:08 +0900 (JST)
Subject: [ruby-changes:43743] nobu:r55816 (trunk): win32.c: static API pointers

nobu	2016-08-05 17:28:03 +0900 (Fri, 05 Aug 2016)

  New Revision: 55816

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55816

  Log:
    win32.c: static API pointers
    
    * win32/win32.c (rb_w32_inet_ntop, rb_w32_inet_): make the
      API pointers static not to get the address everytime.

  Modified files:
    trunk/win32/win32.c
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 55815)
+++ win32/win32.c	(revision 55816)
@@ -7505,8 +7505,9 @@ const char * WSAAPI https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L7505
 rb_w32_inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
 {
     typedef char *(WSAAPI inet_ntop_t)(int, void *, char *, size_t);
-    inet_ntop_t *pInetNtop;
-    pInetNtop = (inet_ntop_t *)get_proc_address("ws2_32", "inet_ntop", NULL);
+    static inet_ntop_t *pInetNtop = (inet_ntop_t *)-1;
+    if (pInetNtop == (inet_ntop_t *)-1)
+	pInetNtop = (inet_ntop_t *)get_proc_address("ws2_32", "inet_ntop", NULL);
     if (pInetNtop) {
 	return pInetNtop(af, (void *)addr, numaddr, numaddr_len);
     }
@@ -7523,8 +7524,9 @@ int WSAAPI https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L7524
 rb_w32_inet_pton(int af, const char *src, void *dst)
 {
     typedef int (WSAAPI inet_pton_t)(int, const char*, void *);
-    inet_pton_t *pInetPton;
-    pInetPton = (inet_pton_t *)get_proc_address("ws2_32", "inet_pton", NULL);
+    static inet_pton_t *pInetPton = (inet_pton_t *)-1;
+    if (pInetPton == (inet_pton_t *)-1)
+	pInetPton = (inet_pton_t *)get_proc_address("ws2_32", "inet_pton", NULL);
     if (pInetPton) {
 	return pInetPton(af, src, dst);
     }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]