aboutsummaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-05 08:28:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-05 08:28:03 +0000
commit1122daf2bfe9671a8cda6a1181f9484eec62aece (patch)
tree801c27576ec92979e5dc4331859f931be452df86 /win32
parentc3a66dae9fd1e898417e2e8707b24afe2b609c96 (diff)
downloadruby-1122daf2bfe9671a8cda6a1181f9484eec62aece.tar.gz
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 02ec9c9f74..1db8e0c078 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -7505,8 +7505,9 @@ const char * WSAAPI
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
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);
}