Skip to content

Commit

Permalink
win32.c: static API pointers
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu committed Aug 5, 2016
1 parent bd46ad2 commit 518af61
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions win32/win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 518af61

Please sign in to comment.