iphlpapi patch 1 - clarify interface counting

Gavriel State gav at transgaming.com
Thu Jan 25 19:14:53 CST 2007


Author: Mark Adams <mark at transgaming.com>

ChangeLog:
- Clarify interface counting

-- 
Gavriel State 
Founder & CTO
TransGaming Technologies Inc.
gav at transgaming.com
http://www.transgaming.com

Broadening The Playing Field

-------------- next part --------------
? dlls/iphlpapi/interface_count_clarify.diff
? dlls/iphlpapi/mac_support.diff
? dlls/iphlpapi/no_ip.diff
Index: dlls/iphlpapi/ifenum.c
===================================================================
RCS file: /home/wine/wine/dlls/iphlpapi/ifenum.c,v
retrieving revision 1.25
diff -u -r1.25 ifenum.c
--- dlls/iphlpapi/ifenum.c	21 Dec 2006 16:37:51 -0000	1.25
+++ dlls/iphlpapi/ifenum.c	26 Jan 2007 01:11:01 -0000
@@ -673,14 +673,16 @@
     int ioctlRet = 0;
     DWORD guessedNumAddresses = 0, numAddresses = 0;
     caddr_t ifPtr;
+    int lastlen;
 
     ret = NO_ERROR;
     ifc->ifc_len = 0;
     ifc->ifc_buf = NULL;
     /* there is no way to know the interface count beforehand,
        so we need to loop again and again upping our max each time
-       until returned < max */
+       until returned is constant across 2 calls */
     do {
+      lastlen = ifc->ifc_len;
       HeapFree(GetProcessHeap(), 0, ifc->ifc_buf);
       if (guessedNumAddresses == 0)
         guessedNumAddresses = INITIAL_INTERFACES_ASSUMED;
@@ -689,8 +691,7 @@
       ifc->ifc_len = sizeof(struct ifreq) * guessedNumAddresses;
       ifc->ifc_buf = HeapAlloc(GetProcessHeap(), 0, ifc->ifc_len);
       ioctlRet = ioctl(fd, SIOCGIFCONF, ifc);
-    } while (ioctlRet == 0 &&
-     ifc->ifc_len > (sizeof(struct ifreq) * (guessedNumAddresses - 2)));
+    } while ((ioctlRet == 0) && (ifc->ifc_len != lastlen));
 
     if (ioctlRet == 0) {
       ifPtr = ifc->ifc_buf;


More information about the wine-patches mailing list