summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-10 05:19:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-10 05:19:25 +0000
commit3c402604dbcad8573fdcdeda4d84406a66740a7a (patch)
treecebd2c9e535fe2d4fffa46571fba25e92e480e36 /win32/win32.c
parent919ab7a3ac69315755211a16666bd3de44cffcc9 (diff)
win32.c: use ruby_strdup
* win32/win32.c (getifaddrs): use ruby_strdup instead of combination ruby_xmalloc, lstrlen and lstrcpy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/win32/win32.c b/win32/win32.c
index f9191f8..a045f89 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -23,6 +23,7 @@
#include "ruby/ruby.h"
#include "ruby/encoding.h"
+#include "ruby/util.h"
#include <fcntl.h>
#include <process.h>
#include <sys/stat.h>
@@ -3937,12 +3938,10 @@ getifaddrs(struct ifaddrs **ifap)
if (pConvertInterfaceGuidToLuid && pConvertInterfaceLuidToNameA &&
pConvertInterfaceGuidToLuid(&guid, &luid) == NO_ERROR &&
pConvertInterfaceLuidToNameA(&luid, name, sizeof(name)) == NO_ERROR) {
- ifa->ifa_name = ruby_xmalloc(lstrlen(name) + 1);
- lstrcpy(ifa->ifa_name, name);
+ ifa->ifa_name = ruby_strdup(name);
}
else {
- ifa->ifa_name = ruby_xmalloc(lstrlen(addr->AdapterName) + 1);
- lstrcpy(ifa->ifa_name, addr->AdapterName);
+ ifa->ifa_name = ruby_strdup(addr->AdapterName);
}
if (addr->IfType & IF_TYPE_SOFTWARE_LOOPBACK)
@@ -3962,9 +3961,7 @@ getifaddrs(struct ifaddrs **ifap)
prev = ifa;
ifa = ruby_xcalloc(1, sizeof(*ifa));
prev->ifa_next = ifa;
- ifa->ifa_name =
- ruby_xmalloc(lstrlen(prev->ifa_name) + 1);
- lstrcpy(ifa->ifa_name, prev->ifa_name);
+ ifa->ifa_name = ruby_strdup(prev->ifa_name);
ifa->ifa_flags = prev->ifa_flags;
}
ifa->ifa_addr = ruby_xmalloc(cur->Address.iSockaddrLength);