Mark Adams : iphlpapi: Clarify interface counting.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jan 26 07:47:02 CST 2007


Module: wine
Branch: master
Commit: a91d69190ee1ab9676aacf05537d5afe8a494e54
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a91d69190ee1ab9676aacf05537d5afe8a494e54

Author: Mark Adams <mark at transgaming.com>
Date:   Thu Jan 25 20:14:53 2007 -0500

iphlpapi: Clarify interface counting.

---

 dlls/iphlpapi/ifenum.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dlls/iphlpapi/ifenum.c b/dlls/iphlpapi/ifenum.c
index fb3348f..c1d1a0a 100644
--- a/dlls/iphlpapi/ifenum.c
+++ b/dlls/iphlpapi/ifenum.c
@@ -673,14 +673,16 @@ static DWORD enumIPAddresses(PDWORD pcAd
     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 @@ static DWORD enumIPAddresses(PDWORD pcAd
       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-cvs mailing list