taskmgr: Replace malloc with HeapAlloc.
This commit is contained in:
parent
50b45a78a3
commit
f3975c5a7e
|
@ -25,7 +25,6 @@
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -173,7 +172,7 @@ static void AddOrUpdateHwnd(HWND hWnd, WCHAR *wszTitle, HICON hIcon, BOOL bHung)
|
||||||
/* It is not already in the list so add it */
|
/* It is not already in the list so add it */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)malloc(sizeof(APPLICATION_PAGE_LIST_ITEM));
|
pAPLI = HeapAlloc(GetProcessHeap(), 0, sizeof(APPLICATION_PAGE_LIST_ITEM));
|
||||||
|
|
||||||
pAPLI->hWnd = hWnd;
|
pAPLI->hWnd = hWnd;
|
||||||
pAPLI->hIcon = hIcon;
|
pAPLI->hIcon = hIcon;
|
||||||
|
@ -212,7 +211,7 @@ static void AddOrUpdateHwnd(HWND hWnd, WCHAR *wszTitle, HICON hIcon, BOOL bHung)
|
||||||
ImageList_Remove(hImageListSmall, item.iItem);
|
ImageList_Remove(hImageListSmall, item.iItem);
|
||||||
|
|
||||||
SendMessage(hApplicationPageListCtrl, LVM_DELETEITEM, item.iItem, 0);
|
SendMessage(hApplicationPageListCtrl, LVM_DELETEITEM, item.iItem, 0);
|
||||||
free(pAPLI);
|
HeapFree(GetProcessHeap(), 0, pAPLI);
|
||||||
bItemRemoved = TRUE;
|
bItemRemoved = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -715,7 +714,8 @@ void ApplicationPage_OnWindowsTileHorizontally(void)
|
||||||
HWND* hWndArray;
|
HWND* hWndArray;
|
||||||
int nWndCount;
|
int nWndCount;
|
||||||
|
|
||||||
hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
hWndArray = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
||||||
nWndCount = 0;
|
nWndCount = 0;
|
||||||
|
|
||||||
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
|
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
|
||||||
|
@ -735,7 +735,7 @@ void ApplicationPage_OnWindowsTileHorizontally(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TileWindows(NULL, MDITILE_HORIZONTAL, NULL, nWndCount, hWndArray);
|
TileWindows(NULL, MDITILE_HORIZONTAL, NULL, nWndCount, hWndArray);
|
||||||
free(hWndArray);
|
HeapFree(GetProcessHeap(), 0, hWndArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationPage_OnWindowsTileVertically(void)
|
void ApplicationPage_OnWindowsTileVertically(void)
|
||||||
|
@ -746,7 +746,8 @@ void ApplicationPage_OnWindowsTileVertically(void)
|
||||||
HWND* hWndArray;
|
HWND* hWndArray;
|
||||||
int nWndCount;
|
int nWndCount;
|
||||||
|
|
||||||
hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
hWndArray = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
||||||
nWndCount = 0;
|
nWndCount = 0;
|
||||||
|
|
||||||
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
|
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
|
||||||
|
@ -766,7 +767,7 @@ void ApplicationPage_OnWindowsTileVertically(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
TileWindows(NULL, MDITILE_VERTICAL, NULL, nWndCount, hWndArray);
|
TileWindows(NULL, MDITILE_VERTICAL, NULL, nWndCount, hWndArray);
|
||||||
free(hWndArray);
|
HeapFree(GetProcessHeap(), 0, hWndArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationPage_OnWindowsMinimize(void)
|
void ApplicationPage_OnWindowsMinimize(void)
|
||||||
|
@ -819,7 +820,8 @@ void ApplicationPage_OnWindowsCascade(void)
|
||||||
HWND* hWndArray;
|
HWND* hWndArray;
|
||||||
int nWndCount;
|
int nWndCount;
|
||||||
|
|
||||||
hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
hWndArray = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
|
||||||
nWndCount = 0;
|
nWndCount = 0;
|
||||||
|
|
||||||
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
|
for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
|
||||||
|
@ -837,7 +839,7 @@ void ApplicationPage_OnWindowsCascade(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CascadeWindows(NULL, 0, NULL, nWndCount, hWndArray);
|
CascadeWindows(NULL, 0, NULL, nWndCount, hWndArray);
|
||||||
free(hWndArray);
|
HeapFree(GetProcessHeap(), 0, hWndArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationPage_OnWindowsBringToFront(void)
|
void ApplicationPage_OnWindowsBringToFront(void)
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -122,10 +121,11 @@ void PerfDataRefresh(void)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get processor time information */
|
/* Get processor time information */
|
||||||
SysProcessorTimeInfo = (PSYSTEM_PROCESSORTIME_INFO)malloc(sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors);
|
SysProcessorTimeInfo = HeapAlloc(GetProcessHeap(), 0,
|
||||||
|
sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors);
|
||||||
status = NtQuerySystemInformation(SystemProcessorTimeInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors, &ulSize);
|
status = NtQuerySystemInformation(SystemProcessorTimeInformation, SysProcessorTimeInfo, sizeof(SYSTEM_PROCESSORTIME_INFO) * SystemBasicInfo.bKeNumberProcessors, &ulSize);
|
||||||
if (status != NO_ERROR) {
|
if (status != NO_ERROR) {
|
||||||
free(SysProcessorTimeInfo);
|
HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,12 +137,12 @@ void PerfDataRefresh(void)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
BufferSize += 0x10000;
|
BufferSize += 0x10000;
|
||||||
SysHandleInfoData = (LPBYTE)malloc(BufferSize);
|
SysHandleInfoData = HeapAlloc(GetProcessHeap(), 0, BufferSize);
|
||||||
|
|
||||||
status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize);
|
status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize);
|
||||||
|
|
||||||
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
|
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
|
||||||
free(SysHandleInfoData);
|
HeapFree(GetProcessHeap(), 0, SysHandleInfoData);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
|
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
|
||||||
|
@ -155,12 +155,12 @@ void PerfDataRefresh(void)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
BufferSize += 0x10000;
|
BufferSize += 0x10000;
|
||||||
pBuffer = (LPBYTE)malloc(BufferSize);
|
pBuffer = HeapAlloc(GetProcessHeap(), 0, BufferSize);
|
||||||
|
|
||||||
status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize);
|
status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize);
|
||||||
|
|
||||||
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
|
if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
|
||||||
free(pBuffer);
|
HeapFree(GetProcessHeap(), 0, pBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
|
} while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
|
||||||
|
@ -180,14 +180,14 @@ void PerfDataRefresh(void)
|
||||||
/*
|
/*
|
||||||
* Save system processor time info
|
* Save system processor time info
|
||||||
*/
|
*/
|
||||||
free(SystemProcessorTimeInfo);
|
HeapFree(GetProcessHeap(), 0, SystemProcessorTimeInfo);
|
||||||
SystemProcessorTimeInfo = SysProcessorTimeInfo;
|
SystemProcessorTimeInfo = SysProcessorTimeInfo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Save system handle info
|
* Save system handle info
|
||||||
*/
|
*/
|
||||||
memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION));
|
memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION));
|
||||||
free(SysHandleInfoData);
|
HeapFree(GetProcessHeap(), 0, SysHandleInfoData);
|
||||||
|
|
||||||
for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.bKeNumberProcessors; Idx++) {
|
for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.bKeNumberProcessors; Idx++) {
|
||||||
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
|
CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
|
||||||
|
@ -231,9 +231,9 @@ void PerfDataRefresh(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now alloc a new PERFDATA array and fill in the data */
|
/* Now alloc a new PERFDATA array and fill in the data */
|
||||||
free(pPerfDataOld);
|
HeapFree(GetProcessHeap(), 0, pPerfDataOld);
|
||||||
pPerfDataOld = pPerfData;
|
pPerfDataOld = pPerfData;
|
||||||
pPerfData = (PPERFDATA)malloc(sizeof(PERFDATA) * ProcessCount);
|
pPerfData = HeapAlloc(GetProcessHeap(), 0, sizeof(PERFDATA) * ProcessCount);
|
||||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
|
pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
|
||||||
for (Idx=0; Idx<ProcessCount; Idx++) {
|
for (Idx=0; Idx<ProcessCount; Idx++) {
|
||||||
/* Get the old perf data for this process (if any) */
|
/* Get the old perf data for this process (if any) */
|
||||||
|
@ -321,7 +321,7 @@ int MultiByteToWideChar(
|
||||||
pPerfData[Idx].KernelTime.QuadPart = pSPI->KernelTime.QuadPart;
|
pPerfData[Idx].KernelTime.QuadPart = pSPI->KernelTime.QuadPart;
|
||||||
pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset);
|
pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset);
|
||||||
}
|
}
|
||||||
free(pBuffer);
|
HeapFree(GetProcessHeap(), 0, pBuffer);
|
||||||
LeaveCriticalSection(&PerfDataCriticalSection);
|
LeaveCriticalSection(&PerfDataCriticalSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
|
|
Loading…
Reference in New Issue