Replace calloc() by HeapAlloc().

This commit is contained in:
Alexandre Julliard 2005-03-11 13:25:42 +00:00
parent bf08b35c07
commit 2444f4af09
1 changed files with 19 additions and 20 deletions

View File

@ -170,7 +170,7 @@ DWORD WINAPI WsControl(DWORD protocol,
ifTable = 0; ifTable = 0;
GetIfTable(NULL, &ifTable, FALSE); GetIfTable(NULL, &ifTable, FALSE);
table = (PMIB_IFTABLE)calloc(1, ifTable); table = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, ifTable );
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
GetIfTable(table, &ifTable, FALSE); GetIfTable(table, &ifTable, FALSE);
@ -178,8 +178,8 @@ DWORD WINAPI WsControl(DWORD protocol,
spaceNeeded = sizeof(TDIEntityID) * (table->dwNumEntries + 4); spaceNeeded = sizeof(TDIEntityID) * (table->dwNumEntries + 4);
if (*pcbResponseInfoLen < spaceNeeded) if (*pcbResponseInfoLen < spaceNeeded)
{ {
free(table); HeapFree( GetProcessHeap(), 0, table );
return (ERROR_LOCK_VIOLATION); return ERROR_LOCK_VIOLATION;
} }
memset(baseptr, 0, spaceNeeded); memset(baseptr, 0, spaceNeeded);
@ -212,8 +212,7 @@ DWORD WINAPI WsControl(DWORD protocol,
} }
*pcbResponseInfoLen = spaceNeeded; *pcbResponseInfoLen = spaceNeeded;
free(table); HeapFree( GetProcessHeap(), 0, table );
break; break;
} }
@ -288,7 +287,7 @@ DWORD WINAPI WsControl(DWORD protocol,
if (*pcbResponseInfoLen < sizeof(ULONG) * 2) if (*pcbResponseInfoLen < sizeof(ULONG) * 2)
return (ERROR_LOCK_VIOLATION); return (ERROR_LOCK_VIOLATION);
GetIpNetTable(NULL, &size, FALSE); GetIpNetTable(NULL, &size, FALSE);
table = (PMIB_IPNETTABLE)calloc(1, size); table = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
GetIpNetTable(table, &size, FALSE); GetIpNetTable(table, &size, FALSE);
@ -302,7 +301,7 @@ DWORD WINAPI WsControl(DWORD protocol,
*/ */
*(output++) = table->dwNumEntries; *(output++) = table->dwNumEntries;
*output = table->table[0].dwIndex; *output = table->table[0].dwIndex;
free(table); HeapFree( GetProcessHeap(), 0, table );
*pcbResponseInfoLen = sizeof(ULONG) * 2; *pcbResponseInfoLen = sizeof(ULONG) * 2;
} }
break; break;
@ -400,7 +399,7 @@ DWORD WINAPI WsControl(DWORD protocol,
gets just one entry. */ gets just one entry. */
tableSize = 0; tableSize = 0;
GetIpAddrTable(NULL, &tableSize, FALSE); GetIpAddrTable(NULL, &tableSize, FALSE);
table = (PMIB_IPADDRTABLE)calloc(1, tableSize); table = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, tableSize );
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
GetIpAddrTable(table, &tableSize, FALSE); GetIpAddrTable(table, &tableSize, FALSE);
@ -415,7 +414,7 @@ DWORD WINAPI WsControl(DWORD protocol,
break; break;
} }
} }
free(table); HeapFree( GetProcessHeap(), 0, table );
*pcbResponseInfoLen = sizeof(MIB_IPADDRROW); *pcbResponseInfoLen = sizeof(MIB_IPADDRROW);
break; break;
@ -447,12 +446,12 @@ DWORD WINAPI WsControl(DWORD protocol,
0) / sizeof(MIB_IPFORWARDROW) + 1; 0) / sizeof(MIB_IPFORWARDROW) + 1;
if (*pcbResponseInfoLen < sizeof(IPRouteEntry) * numRoutes) if (*pcbResponseInfoLen < sizeof(IPRouteEntry) * numRoutes)
return (ERROR_LOCK_VIOLATION); return (ERROR_LOCK_VIOLATION);
table = (PMIB_IPFORWARDTABLE)calloc(1, routeTableSize); table = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, routeTableSize );
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
ret = GetIpForwardTable(table, &routeTableSize, FALSE); ret = GetIpForwardTable(table, &routeTableSize, FALSE);
if (ret != NO_ERROR) { if (ret != NO_ERROR) {
free(table); HeapFree( GetProcessHeap(), 0, table );
return ret; return ret;
} }
@ -480,7 +479,7 @@ DWORD WINAPI WsControl(DWORD protocol,
*pcbResponseInfoLen = sizeof(IPRouteEntry) * *pcbResponseInfoLen = sizeof(IPRouteEntry) *
table->dwNumEntries; table->dwNumEntries;
free(table); HeapFree( GetProcessHeap(), 0, table );
} }
break; break;
@ -496,18 +495,18 @@ DWORD WINAPI WsControl(DWORD protocol,
0) / sizeof(MIB_IPNETROW) + 1; 0) / sizeof(MIB_IPNETROW) + 1;
if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) * numEntries) if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) * numEntries)
return (ERROR_LOCK_VIOLATION); return (ERROR_LOCK_VIOLATION);
table = (PMIB_IPNETTABLE)calloc(1, arpTableSize); table = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, arpTableSize );
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
ret = GetIpNetTable(table, &arpTableSize, FALSE); ret = GetIpNetTable(table, &arpTableSize, FALSE);
if (ret != NO_ERROR) { if (ret != NO_ERROR) {
free(table); HeapFree( GetProcessHeap(), 0, table );
return ret; return ret;
} }
if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) * if (*pcbResponseInfoLen < sizeof(MIB_IPNETROW) *
table->dwNumEntries) table->dwNumEntries)
{ {
free(table); HeapFree( GetProcessHeap(), 0, table );
return ERROR_LOCK_VIOLATION; return ERROR_LOCK_VIOLATION;
} }
memcpy(pResponseInfo, table->table, sizeof(MIB_IPNETROW) * memcpy(pResponseInfo, table->table, sizeof(MIB_IPNETROW) *
@ -517,7 +516,7 @@ DWORD WINAPI WsControl(DWORD protocol,
*pcbResponseInfoLen = sizeof(MIB_IPNETROW) * *pcbResponseInfoLen = sizeof(MIB_IPNETROW) *
table->dwNumEntries; table->dwNumEntries;
free(table); HeapFree( GetProcessHeap(), 0, table );
} }
break; break;
@ -534,18 +533,18 @@ DWORD WINAPI WsControl(DWORD protocol,
0) / sizeof(MIB_TCPROW) + 1; 0) / sizeof(MIB_TCPROW) + 1;
if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) * numEntries) if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) * numEntries)
return (ERROR_LOCK_VIOLATION); return (ERROR_LOCK_VIOLATION);
table = (PMIB_TCPTABLE)calloc(1, tcpTableSize); table = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, tcpTableSize );
if (!table) if (!table)
return ERROR_NOT_ENOUGH_MEMORY; return ERROR_NOT_ENOUGH_MEMORY;
ret = GetTcpTable(table, &tcpTableSize, FALSE); ret = GetTcpTable(table, &tcpTableSize, FALSE);
if (ret != NO_ERROR) { if (ret != NO_ERROR) {
free(table); HeapFree( GetProcessHeap(), 0, table );
return ret; return ret;
} }
if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) * if (*pcbResponseInfoLen < sizeof(MIB_TCPROW) *
table->dwNumEntries) table->dwNumEntries)
{ {
free(table); HeapFree( GetProcessHeap(), 0, table );
return ERROR_LOCK_VIOLATION; return ERROR_LOCK_VIOLATION;
} }
for (i = 0; i < table->dwNumEntries; i++) for (i = 0; i < table->dwNumEntries; i++)
@ -564,7 +563,7 @@ DWORD WINAPI WsControl(DWORD protocol,
*pcbResponseInfoLen = sizeof(MIB_TCPROW) * *pcbResponseInfoLen = sizeof(MIB_TCPROW) *
table->dwNumEntries; table->dwNumEntries;
free(table); HeapFree( GetProcessHeap(), 0, table );
} }
break; break;