1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2015-08-10 05:19:25 +00:00
parent 919ab7a3ac
commit 3c402604db
2 changed files with 5 additions and 8 deletions

View file

@ -711,7 +711,7 @@ prelude.$(OBJEXT): {$(VPATH)}prelude.c
compile.$(OBJEXT): {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc
win32/win32.$(OBJEXT): {$(VPATH)}win32/win32.c {$(VPATH)}dln.h {$(VPATH)}dln_find.c \
{$(VPATH)}internal.h $(RUBY_H_INCLUDES) $(PLATFORM_D)
{$(VPATH)}internal.h {$(VPATH)}util.h $(RUBY_H_INCLUDES) $(PLATFORM_D)
win32/file.$(OBJEXT): {$(VPATH)}win32/file.c {$(VPATH)}thread.h \
$(RUBY_H_INCLUDES) $(PLATFORM_D)

View file

@ -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);