taskmgr: Replace malloc with HeapAlloc.

Michael Stefaniuc mstefani at redhat.de
Sun Dec 7 21:07:31 CST 2008


---
 programs/taskmgr/about.c    |    1 -
 programs/taskmgr/affinity.c |    1 -
 programs/taskmgr/applpage.c |   20 +++++++++++---------
 programs/taskmgr/column.c   |    1 -
 programs/taskmgr/dbgchnl.c  |    1 -
 programs/taskmgr/debug.c    |    1 -
 programs/taskmgr/endproc.c  |    1 -
 programs/taskmgr/graph.c    |    1 -
 programs/taskmgr/graphctl.c |    1 -
 programs/taskmgr/optnmenu.c |    1 -
 programs/taskmgr/perfdata.c |   24 ++++++++++++------------
 programs/taskmgr/perfpage.c |    1 -
 programs/taskmgr/priority.c |    1 -
 programs/taskmgr/proclist.c |    1 -
 programs/taskmgr/procpage.c |    1 -
 programs/taskmgr/run.c      |    1 -
 programs/taskmgr/taskmgr.c  |    1 -
 programs/taskmgr/trayicon.c |    1 -
 18 files changed, 23 insertions(+), 37 deletions(-)

diff --git a/programs/taskmgr/about.c b/programs/taskmgr/about.c
index 948c7ea..68d64ca 100644
--- a/programs/taskmgr/about.c
+++ b/programs/taskmgr/about.c
@@ -25,7 +25,6 @@
 #include <commctrl.h>
 #include <stdlib.h>
 #include <shellapi.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/affinity.c b/programs/taskmgr/affinity.c
index 1b6d20e..31a4f64 100644
--- a/programs/taskmgr/affinity.c
+++ b/programs/taskmgr/affinity.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <winnt.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/applpage.c b/programs/taskmgr/applpage.c
index f6fbf16..20248d4 100644
--- a/programs/taskmgr/applpage.c
+++ b/programs/taskmgr/applpage.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.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 */
     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->hIcon = hIcon;
@@ -212,7 +211,7 @@ static void AddOrUpdateHwnd(HWND hWnd, WCHAR *wszTitle, HICON hIcon, BOOL bHung)
             ImageList_Remove(hImageListSmall, item.iItem);
 
             SendMessage(hApplicationPageListCtrl, LVM_DELETEITEM, item.iItem, 0);
-            free(pAPLI);
+            HeapFree(GetProcessHeap(), 0, pAPLI);
             bItemRemoved = TRUE;
         }
     }
@@ -715,7 +714,8 @@ void ApplicationPage_OnWindowsTileHorizontally(void)
     HWND*                           hWndArray;
     int                             nWndCount;
 
-    hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
+    hWndArray = HeapAlloc(GetProcessHeap(), 0,
+                    sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
     nWndCount = 0;
 
     for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
@@ -735,7 +735,7 @@ void ApplicationPage_OnWindowsTileHorizontally(void)
         }
     }
     TileWindows(NULL, MDITILE_HORIZONTAL, NULL, nWndCount, hWndArray);
-    free(hWndArray);
+    HeapFree(GetProcessHeap(), 0, hWndArray);
 }
 
 void ApplicationPage_OnWindowsTileVertically(void)
@@ -746,7 +746,8 @@ void ApplicationPage_OnWindowsTileVertically(void)
     HWND*                           hWndArray;
     int                             nWndCount;
 
-    hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
+    hWndArray = HeapAlloc(GetProcessHeap(), 0,
+                    sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
     nWndCount = 0;
 
     for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
@@ -766,7 +767,7 @@ void ApplicationPage_OnWindowsTileVertically(void)
     }
 
     TileWindows(NULL, MDITILE_VERTICAL, NULL, nWndCount, hWndArray);
-    free(hWndArray);
+    HeapFree(GetProcessHeap(), 0, hWndArray);
 }
 
 void ApplicationPage_OnWindowsMinimize(void)
@@ -819,7 +820,8 @@ void ApplicationPage_OnWindowsCascade(void)
     HWND*                           hWndArray;
     int                             nWndCount;
 
-    hWndArray = (HWND*)malloc(sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
+    hWndArray = HeapAlloc(GetProcessHeap(), 0,
+                    sizeof(HWND) * ListView_GetItemCount(hApplicationPageListCtrl));
     nWndCount = 0;
 
     for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) {
@@ -837,7 +839,7 @@ void ApplicationPage_OnWindowsCascade(void)
         }
     }
     CascadeWindows(NULL, 0, NULL, nWndCount, hWndArray);
-    free(hWndArray);
+    HeapFree(GetProcessHeap(), 0, hWndArray);
 }
 
 void ApplicationPage_OnWindowsBringToFront(void)
diff --git a/programs/taskmgr/column.c b/programs/taskmgr/column.c
index 7c0ea21..f64a747 100644
--- a/programs/taskmgr/column.c
+++ b/programs/taskmgr/column.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
     
diff --git a/programs/taskmgr/dbgchnl.c b/programs/taskmgr/dbgchnl.c
index 83d4281..457713c 100644
--- a/programs/taskmgr/dbgchnl.c
+++ b/programs/taskmgr/dbgchnl.c
@@ -26,7 +26,6 @@
 #include <ctype.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/debug.c b/programs/taskmgr/debug.c
index 800f6a5..409a337 100644
--- a/programs/taskmgr/debug.c
+++ b/programs/taskmgr/debug.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/endproc.c b/programs/taskmgr/endproc.c
index 56e665d..241aa67 100644
--- a/programs/taskmgr/endproc.c
+++ b/programs/taskmgr/endproc.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/graph.c b/programs/taskmgr/graph.c
index 821100c..5e26ead 100644
--- a/programs/taskmgr/graph.c
+++ b/programs/taskmgr/graph.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/graphctl.c b/programs/taskmgr/graphctl.c
index 7b5db77..8b6d98d 100644
--- a/programs/taskmgr/graphctl.c
+++ b/programs/taskmgr/graphctl.c
@@ -24,7 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/optnmenu.c b/programs/taskmgr/optnmenu.c
index 81936dc..726531f 100644
--- a/programs/taskmgr/optnmenu.c
+++ b/programs/taskmgr/optnmenu.c
@@ -30,7 +30,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/perfdata.c b/programs/taskmgr/perfdata.c
index cda872d..5a24ba3 100644
--- a/programs/taskmgr/perfdata.c
+++ b/programs/taskmgr/perfdata.c
@@ -24,7 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
@@ -122,10 +121,11 @@ void PerfDataRefresh(void)
         return;
 
     /* 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);
     if (status != NO_ERROR) {
-        free(SysProcessorTimeInfo);
+        HeapFree(GetProcessHeap(), 0, SysProcessorTimeInfo);
         return;
     }
 
@@ -137,12 +137,12 @@ void PerfDataRefresh(void)
     do
     {
         BufferSize += 0x10000;
-        SysHandleInfoData = (LPBYTE)malloc(BufferSize);
+        SysHandleInfoData = HeapAlloc(GetProcessHeap(), 0, BufferSize);
 
         status = NtQuerySystemInformation(SystemHandleInformation, SysHandleInfoData, BufferSize, &ulSize);
 
         if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
-            free(SysHandleInfoData);
+            HeapFree(GetProcessHeap(), 0, SysHandleInfoData);
         }
 
     } while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
@@ -155,12 +155,12 @@ void PerfDataRefresh(void)
     do
     {
         BufferSize += 0x10000;
-        pBuffer = (LPBYTE)malloc(BufferSize);
+        pBuffer = HeapAlloc(GetProcessHeap(), 0, BufferSize);
 
         status = NtQuerySystemInformation(SystemProcessInformation, pBuffer, BufferSize, &ulSize);
 
         if (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/) {
-            free(pBuffer);
+            HeapFree(GetProcessHeap(), 0, pBuffer);
         }
 
     } while (status == 0xC0000004 /*STATUS_INFO_LENGTH_MISMATCH*/);
@@ -180,14 +180,14 @@ void PerfDataRefresh(void)
     /*
      * Save system processor time info
      */
-    free(SystemProcessorTimeInfo);
+    HeapFree(GetProcessHeap(), 0, SystemProcessorTimeInfo);
     SystemProcessorTimeInfo = SysProcessorTimeInfo;
     
     /*
      * Save system handle info
      */
     memcpy(&SystemHandleInfo, SysHandleInfoData, sizeof(SYSTEM_HANDLE_INFORMATION));
-    free(SysHandleInfoData);
+    HeapFree(GetProcessHeap(), 0, SysHandleInfoData);
     
     for (CurrentKernelTime=0, Idx=0; Idx<SystemBasicInfo.bKeNumberProcessors; Idx++) {
         CurrentKernelTime += Li2Double(SystemProcessorTimeInfo[Idx].KernelTime);
@@ -231,9 +231,9 @@ void PerfDataRefresh(void)
     }
 
     /* Now alloc a new PERFDATA array and fill in the data */
-    free(pPerfDataOld);
+    HeapFree(GetProcessHeap(), 0, pPerfDataOld);
     pPerfDataOld = pPerfData;
-    pPerfData = (PPERFDATA)malloc(sizeof(PERFDATA) * ProcessCount);
+    pPerfData = HeapAlloc(GetProcessHeap(), 0, sizeof(PERFDATA) * ProcessCount);
     pSPI = (PSYSTEM_PROCESS_INFORMATION)pBuffer;
     for (Idx=0; Idx<ProcessCount; Idx++) {
         /* Get the old perf data for this process (if any) */
@@ -321,7 +321,7 @@ int MultiByteToWideChar(
         pPerfData[Idx].KernelTime.QuadPart = pSPI->KernelTime.QuadPart;
         pSPI = (PSYSTEM_PROCESS_INFORMATION)((LPBYTE)pSPI + pSPI->RelativeOffset);
     }
-    free(pBuffer);
+    HeapFree(GetProcessHeap(), 0, pBuffer);
     LeaveCriticalSection(&PerfDataCriticalSection);
 }
 
diff --git a/programs/taskmgr/perfpage.c b/programs/taskmgr/perfpage.c
index 4bf69c6..e5f1435 100644
--- a/programs/taskmgr/perfpage.c
+++ b/programs/taskmgr/perfpage.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/priority.c b/programs/taskmgr/priority.c
index cd3a523..360fe16 100644
--- a/programs/taskmgr/priority.c
+++ b/programs/taskmgr/priority.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/proclist.c b/programs/taskmgr/proclist.c
index f50bc1d..07151c0 100644
--- a/programs/taskmgr/proclist.c
+++ b/programs/taskmgr/proclist.c
@@ -24,7 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/procpage.c b/programs/taskmgr/procpage.c
index 3450f83..adbf469 100644
--- a/programs/taskmgr/procpage.c
+++ b/programs/taskmgr/procpage.c
@@ -24,7 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/run.c b/programs/taskmgr/run.c
index 1954e9f..8ab2935 100644
--- a/programs/taskmgr/run.c
+++ b/programs/taskmgr/run.c
@@ -24,7 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <tchar.h>
 #include <stdio.h>
diff --git a/programs/taskmgr/taskmgr.c b/programs/taskmgr/taskmgr.c
index c765b74..8d05ca6 100644
--- a/programs/taskmgr/taskmgr.c
+++ b/programs/taskmgr/taskmgr.c
@@ -25,7 +25,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
diff --git a/programs/taskmgr/trayicon.c b/programs/taskmgr/trayicon.c
index 90705ec..36a2bcc 100644
--- a/programs/taskmgr/trayicon.c
+++ b/programs/taskmgr/trayicon.c
@@ -24,7 +24,6 @@
 #include <windows.h>
 #include <commctrl.h>
 #include <stdlib.h>
-#include <malloc.h>
 #include <memory.h>
 #include <stdio.h>
 #include <winnt.h>
-- 
1.6.1.rc1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20081208/87318d4c/attachment-0001.pgp 


More information about the wine-patches mailing list