From d466fa96727cdf0087367cb40dcba286ecec1878 Mon Sep 17 00:00:00 2001 From: glx Date: Wed, 8 Apr 2009 00:10:20 +0000 Subject: [PATCH] (svn r15974) -Fix (r15969): win32 compilation was broken (again) --- src/network/core/host.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp index 14fe4f303f..7b7f22784b 100644 --- a/src/network/core/host.cpp +++ b/src/network/core/host.cpp @@ -112,11 +112,18 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // Wi if (sock == INVALID_SOCKET) return; DWORD len = 0; - INTERFACE_INFO *ifo = AllocaM(INTERFACE_INFO, limit); - memset(ifo, 0, limit * sizeof(*ifo)); - if ((WSAIoctl(sock, SIO_GET_INTERFACE_LIST, NULL, 0, &ifo[0], limit * sizeof(*ifo), &len, NULL, NULL)) != 0) { - closesocket(sock); - return; + int num = 2; + INTERFACE_INFO *ifo = CallocT(num); + + for(;;) { + if (WSAIoctl(sock, SIO_GET_INTERFACE_LIST, NULL, 0, ifo, num * sizeof(*ifo), &len, NULL, NULL) == 0) break; + free(ifo); + if (WSAGetLastError() != WSAEFAULT) { + closesocket(sock); + return; + } + num *= 2; + ifo = CallocT(num); } for (uint j = 0; j < len / sizeof(*ifo); j++) { @@ -131,6 +138,7 @@ static void NetworkFindBroadcastIPsInternal(NetworkAddressList *broadcast) // Wi *broadcast->Append() = NetworkAddress(address, sizeof(sockaddr)); } + free(ifo); closesocket(sock); }