iphlpapi: Don't allocate gobs of memory if there are no non-loopback interfaces.

This commit is contained in:
Juan Lang 2007-11-15 11:06:50 -08:00 committed by Alexandre Julliard
parent e1a836933f
commit 0502de41ae
1 changed files with 4 additions and 2 deletions

View File

@ -234,12 +234,14 @@ InterfaceIndexTable *getNonLoopbackInterfaceIndexTable(void)
if (indexes) {
struct if_nameindex *p;
DWORD size = sizeof(InterfaceIndexTable);
for (p = indexes, numInterfaces = 0; p && p->if_name; p++)
if (!isLoopbackInterface(fd, p->if_name))
numInterfaces++;
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(InterfaceIndexTable) + (numInterfaces - 1) * sizeof(DWORD));
if (numInterfaces > 1)
size += (numInterfaces - 1) * sizeof(DWORD);
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (ret) {
for (p = indexes; p && p->if_name; p++)
if (!isLoopbackInterface(fd, p->if_name))