SHELL32: use Heap function in preference to malloc/free

Mike McCormack mike at codeweavers.com
Mon Aug 9 05:40:25 CDT 2004


ChangeLog:
* use Heap function in preference to malloc/free
-------------- next part --------------
Index: dlls/shell32/dialogs.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/dialogs.c,v
retrieving revision 1.19
diff -u -r1.19 dialogs.c
--- dlls/shell32/dialogs.c	2 Aug 2004 18:48:21 -0000	1.19
+++ dlls/shell32/dialogs.c	9 Aug 2004 09:18:53 -0000
@@ -142,7 +142,7 @@
                     HWND htxt = NULL ;
                     if ((ic = GetWindowTextLengthA (htxt = GetDlgItem (hwnd, 12298))))
                         {
-                        psz = malloc (ic + 2) ;
+                        psz = HeapAlloc( GetProcessHeap, 0, (ic + 2) );
                         GetWindowTextA (htxt, psz, ic + 1) ;
 
                         if (ShellExecuteA(NULL, "open", psz, NULL, NULL, SW_SHOWNORMAL) < (HINSTANCE)33)
@@ -160,12 +160,12 @@
                             LocalFree ((HLOCAL)pszSysMsg) ;
                             MessageBoxA (hwnd, szMsg, "Nix", MB_OK | MB_ICONEXCLAMATION) ;
 
-                            free (psz) ;
+                            HeapFree(GetProcessHeap(), 0, psz);
                             SendMessageA (htxt, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
                             return TRUE ;
                             }
                         FillList (htxt, psz) ;
-                        free (psz) ;
+                        HeapFree(GetProcessHeap(), 0, psz);
                         EndDialog (hwnd, 0) ;
                         }
                     }
@@ -254,13 +254,14 @@
 
     if (icList > 0)
         {
-        pszList = malloc (icList) ;
+        pszList = HeapAlloc( GetProcessHeap(), 0, icList) ;
         if (ERROR_SUCCESS != RegQueryValueExA (hkey, "MRUList", NULL, NULL, pszList, &icList))
             MessageBoxA (hCb, "Unable to grab MRUList !", "Nix", MB_OK) ;
         }
     else
         {
-        pszList = malloc (icList = 1) ;
+        icList = 1 ;
+        pszList = HeapAlloc( GetProcessHeap(), 0, icList) ;
         pszList[0] = 0 ;
         }
 
@@ -273,7 +274,10 @@
 
         if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, NULL, &icCmd))
             MessageBoxA (hCb, "Unable to grab size of index", "Nix", MB_OK) ;
-        pszCmd = realloc (pszCmd, icCmd) ;
+        if( pszCmd )
+            pszCmd = HeapReAlloc(GetProcessHeap(), 0, pszCmd, icCmd) ;
+        else
+            pszCmd = HeapAlloc(GetProcessHeap(), 0, icCmd) ;
         if (ERROR_SUCCESS != RegQueryValueExA (hkey, szIndex, NULL, NULL, pszCmd, &icCmd))
             MessageBoxA (hCb, "Unable to grab index", "Nix", MB_OK) ;
 
@@ -339,7 +343,10 @@
         SendMessageA (hCb, CB_SETEDITSEL, 0, MAKELPARAM (0, -1)) ;
 
         cMatch = ++cMax ;
-        pszList = realloc (pszList, ++icList) ;
+        if( pszList )
+            pszList = HeapReAlloc(GetProcessHeap(), 0, pszList, ++icList) ;
+        else
+            pszList = HeapAlloc(GetProcessHeap(), 0, ++icList) ;
         memmove (&pszList[1], pszList, icList - 1) ;
         pszList[0] = cMatch ;
         szIndex[0] = cMatch ;
@@ -348,8 +355,8 @@
 
     RegSetValueExA (hkey, "MRUList", 0, REG_SZ, pszList, strlen (pszList) + 1) ;
 
-    free (pszCmd) ;
-    free (pszList) ;
+    HeapFree( GetProcessHeap(), 0, pszCmd) ;
+    HeapFree( GetProcessHeap(), 0, pszList) ;
     }
 
 
Index: dlls/shell32/systray.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/systray.c,v
retrieving revision 1.26
diff -u -r1.26 systray.c
--- dlls/shell32/systray.c	27 Feb 2004 21:30:16 -0000	1.26
+++ dlls/shell32/systray.c	9 Aug 2004 09:18:54 -0000
@@ -28,7 +28,6 @@
 # include <unistd.h>
 #endif
 #include <stdarg.h>
-#include <stdlib.h>
 #include <string.h>
 
 #include "windef.h"
@@ -289,7 +288,7 @@
     ptrayItem = &((*ptrayItem)->nextTrayItem);
   }
   /* Allocate SystrayItem for element and add to end of list. */
-  (*ptrayItem) = ( SystrayItem *)malloc( sizeof(SystrayItem) );
+  (*ptrayItem) = HeapAlloc(GetProcessHeap(),0,sizeof(SystrayItem));
 
   /* Initialize and set data for the tray element. */
   SYSTRAY_ItemInit( (*ptrayItem) );
@@ -337,7 +336,7 @@
       TRACE("%p: %p %s\n", *ptrayItem, (*ptrayItem)->notifyIcon.hWnd, (*ptrayItem)->notifyIcon.szTip);
       SYSTRAY_ItemTerm(*ptrayItem);
 
-      free(*ptrayItem);
+      HeapFree(GetProcessHeap(),0,*ptrayItem);
       *ptrayItem = next;
 
       return TRUE;


More information about the wine-patches mailing list