summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2009-04-08 00:10:20 +0000
committerglx <glx@openttd.org>2009-04-08 00:10:20 +0000
commitd466fa96727cdf0087367cb40dcba286ecec1878 (patch)
tree8f669e0b772aac3a387af4d4ff903d289818e0e4 /src
parent8cf88876efe8ae0a758517e7211a320ed7578db6 (diff)
downloadopenttd-d466fa96727cdf0087367cb40dcba286ecec1878.tar.xz
(svn r15974) -Fix (r15969): win32 compilation was broken (again)
Diffstat (limited to 'src')
-rw-r--r--src/network/core/host.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/network/core/host.cpp b/src/network/core/host.cpp
index 14fe4f303..7b7f22784 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<INTERFACE_INFO>(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<INTERFACE_INFO>(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);
}