From: Rémi Bernon rbernon@codeweavers.com
--- programs/explorer/appbar.c | 4 ++-- programs/explorer/desktop.c | 41 +++++++++++++++++------------------ programs/explorer/explorer.c | 15 +++++-------- programs/explorer/startmenu.c | 12 +++++----- programs/explorer/systray.c | 12 +++++----- 5 files changed, 39 insertions(+), 45 deletions(-)
diff --git a/programs/explorer/appbar.c b/programs/explorer/appbar.c index 443927e30f1..2f96c580e19 100644 --- a/programs/explorer/appbar.c +++ b/programs/explorer/appbar.c @@ -146,7 +146,7 @@ static UINT_PTR handle_appbarmessage(DWORD msg, struct appbar_data_msg *abd) return FALSE; }
- data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct appbar_data)); + data = calloc( 1, sizeof(struct appbar_data) ); if (!data) { WINE_ERR("out of memory\n"); @@ -165,7 +165,7 @@ static UINT_PTR handle_appbarmessage(DWORD msg, struct appbar_data_msg *abd)
send_poschanged(hwnd);
- HeapFree(GetProcessHeap(), 0, data); + free( data ); } else WINE_WARN("removing hwnd %p not on the list\n", hwnd); diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index 1610814048e..79652cbbc3b 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -288,8 +288,7 @@ static WCHAR *append_path( const WCHAR *path, const WCHAR *filename, int len_fil WCHAR *ret;
if (len_filename == -1) len_filename = lstrlenW( filename ); - if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len_path + len_filename + 2) * sizeof(WCHAR) ))) - return NULL; + if (!(ret = malloc( (len_path + len_filename + 2) * sizeof(WCHAR) ))) return NULL; memcpy( ret, path, len_path * sizeof(WCHAR) ); ret[len_path] = '\'; memcpy( ret + len_path + 1, filename, len_filename * sizeof(WCHAR) ); @@ -358,7 +357,7 @@ static WCHAR *build_title( const WCHAR *filename, int len ) break; } } - if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL; + if (!(ret = malloc( (len + 1) * sizeof(WCHAR) ))) return NULL; memcpy( ret, filename, len * sizeof(WCHAR) ); ret[len] = 0; return ret; @@ -372,13 +371,13 @@ static BOOL add_launcher( const WCHAR *folder, const WCHAR *filename, int len_fi if (nb_launchers == nb_allocated) { unsigned int count = nb_allocated * 2; - struct launcher **tmp = HeapReAlloc( GetProcessHeap(), 0, launchers, count * sizeof(*tmp) ); + struct launcher **tmp = realloc( launchers, count * sizeof(*tmp) ); if (!tmp) return FALSE; launchers = tmp; nb_allocated = count; }
- if (!(launcher = HeapAlloc( GetProcessHeap(), 0, sizeof(*launcher) ))) return FALSE; + if (!(launcher = malloc( sizeof(*launcher) ))) return FALSE; if (!(launcher->path = append_path( folder, filename, len_filename ))) goto error; if (!(link = load_shelllink( launcher->path ))) goto error;
@@ -390,21 +389,21 @@ static BOOL add_launcher( const WCHAR *folder, const WCHAR *filename, int len_fi launchers[nb_launchers++] = launcher; return TRUE; } - HeapFree( GetProcessHeap(), 0, launcher->title ); + free( launcher->title ); DestroyIcon( launcher->icon );
error: - HeapFree( GetProcessHeap(), 0, launcher->path ); - HeapFree( GetProcessHeap(), 0, launcher ); + free( launcher->path ); + free( launcher ); return FALSE; }
static void free_launcher( struct launcher *launcher ) { DestroyIcon( launcher->icon ); - HeapFree( GetProcessHeap(), 0, launcher->path ); - HeapFree( GetProcessHeap(), 0, launcher->title ); - HeapFree( GetProcessHeap(), 0, launcher ); + free( launcher->path ); + free( launcher->title ); + free( launcher ); }
static BOOL remove_launcher( const WCHAR *folder, const WCHAR *filename, int len_filename ) @@ -425,7 +424,7 @@ static BOOL remove_launcher( const WCHAR *folder, const WCHAR *filename, int len break; } } - HeapFree( GetProcessHeap(), 0, path ); + free( path ); return ret; }
@@ -498,8 +497,8 @@ static DWORD CALLBACK watch_desktop_folders( LPVOID param ) } if (!(ovl0.hEvent = events[0] = CreateEventW( NULL, FALSE, FALSE, NULL ))) goto error; if (!(ovl1.hEvent = events[1] = CreateEventW( NULL, FALSE, FALSE, NULL ))) goto error; - if (!(buf0 = HeapAlloc( GetProcessHeap(), 0, size ))) goto error; - if (!(buf1 = HeapAlloc( GetProcessHeap(), 0, size ))) goto error; + if (!(buf0 = malloc( size ))) goto error; + if (!(buf1 = malloc( size ))) goto error;
for (;;) { @@ -540,8 +539,8 @@ error: CloseHandle( dir1 ); CloseHandle( events[0] ); CloseHandle( events[1] ); - HeapFree( GetProcessHeap(), 0, buf0 ); - HeapFree( GetProcessHeap(), 0, buf1 ); + free( buf0 ); + free( buf1 ); if (SUCCEEDED( init )) CoUninitialize(); return error; } @@ -554,7 +553,7 @@ static void add_folder( const WCHAR *folder ) HANDLE handle; WCHAR *glob;
- if (!(glob = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return; + if (!(glob = malloc( (len + 1) * sizeof(WCHAR) ))) return; lstrcpyW( glob, folder ); lstrcatW( glob, lnkW );
@@ -563,7 +562,7 @@ static void add_folder( const WCHAR *folder ) do { add_launcher( folder, data.cFileName, -1 ); } while (FindNextFileW( handle, &data )); FindClose( handle ); } - HeapFree( GetProcessHeap(), 0, glob ); + free( glob ); }
#define BORDER_SIZE 4 @@ -605,7 +604,7 @@ static void initialize_launchers( HWND hwnd ) CoTaskMemFree( desktop_folder ); return; } - if ((launchers = HeapAlloc( GetProcessHeap(), 0, 2 * sizeof(launchers[0]) ))) + if ((launchers = malloc( 2 * sizeof(launchers[0]) ))) { nb_allocated = 2;
@@ -996,7 +995,7 @@ static void set_desktop_window_title( HWND hwnd, const WCHAR *name ) window_title_len = lstrlenW(name) * sizeof(WCHAR) + sizeof(desktop_name_separatorW) + sizeof(desktop_nameW); - window_titleW = HeapAlloc( GetProcessHeap(), 0, window_title_len ); + window_titleW = malloc( window_title_len ); if (!window_titleW) { SetWindowTextW( hwnd, desktop_nameW ); @@ -1008,7 +1007,7 @@ static void set_desktop_window_title( HWND hwnd, const WCHAR *name ) lstrcatW( window_titleW, desktop_nameW );
SetWindowTextW( hwnd, window_titleW ); - HeapFree( GetProcessHeap(), 0, window_titleW ); + free( window_titleW ); }
static inline BOOL is_whitespace(WCHAR c) diff --git a/programs/explorer/explorer.c b/programs/explorer/explorer.c index 7924991383f..8960ac62d81 100644 --- a/programs/explorer/explorer.c +++ b/programs/explorer/explorer.c @@ -23,7 +23,6 @@ #define COBJMACROS
#include "wine/debug.h" -#include "wine/heap.h" #include "explorer_private.h" #include "resource.h"
@@ -114,8 +113,7 @@ static ULONG WINAPI IExplorerBrowserEventsImpl_fnRelease(IExplorerBrowserEvents { IExplorerBrowserEventsImpl *This = impl_from_IExplorerBrowserEvents(iface); ULONG ref = InterlockedDecrement(&This->ref); - if(!ref) - HeapFree(GetProcessHeap(),0,This); + if(!ref) free(This); return ref; }
@@ -334,8 +332,7 @@ static IExplorerBrowserEventsVtbl vt_IExplorerBrowserEvents =
static IExplorerBrowserEvents *make_explorer_events(explorer_info *info) { - IExplorerBrowserEventsImpl *ret - = HeapAlloc(GetProcessHeap(), 0, sizeof(IExplorerBrowserEventsImpl)); + IExplorerBrowserEventsImpl *ret = malloc( sizeof(IExplorerBrowserEventsImpl) ); ret->IExplorerBrowserEvents_iface.lpVtbl = &vt_IExplorerBrowserEvents; ret->info = info; ret->ref = 1; @@ -447,7 +444,7 @@ static void make_explorer_window(parameters_struct *params) default_width = MulDiv(DEFAULT_WIDTH, dpix, USER_DEFAULT_SCREEN_DPI); default_height = MulDiv(DEFAULT_HEIGHT, dpiy, USER_DEFAULT_SCREEN_DPI);
- info = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(explorer_info)); + info = calloc( 1, sizeof(explorer_info) ); if(!info) { WINE_ERR("Could not allocate an explorer_info struct\n"); @@ -459,8 +456,8 @@ static void make_explorer_window(parameters_struct *params) &IID_IExplorerBrowser,(LPVOID*)&info->browser); if(FAILED(hres)) { - WINE_ERR("Could not obtain an instance of IExplorerBrowser\n"); - HeapFree(GetProcessHeap(),0,info); + WINE_ERR( "Could not obtain an instance of IExplorerBrowser\n" ); + free(info); IShellWindows_Release(sw); free(path); return; @@ -727,7 +724,7 @@ static LRESULT CALLBACK explorer_wnd_proc(HWND hwnd, UINT uMsg, WPARAM wParam, L IExplorerBrowser_Release(browser); ILFree(info->pidl); IImageList_Release(info->icon_list); - HeapFree(GetProcessHeap(),0,info); + free(info); SetWindowLongPtrW(hwnd,EXPLORER_INFO_INDEX,0); PostQuitMessage(0); break; diff --git a/programs/explorer/startmenu.c b/programs/explorer/startmenu.c index b46bd068220..0a6ef5f9c25 100644 --- a/programs/explorer/startmenu.c +++ b/programs/explorer/startmenu.c @@ -185,7 +185,7 @@ static struct menu_item* add_shell_item(struct menu_item* parent, LPITEMIDLIST p BOOL match = FALSE; SFGAOF flags;
- item = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct menu_item)); + item = calloc( 1, sizeof(struct menu_item) );
if (parent->pidl == NULL) { @@ -208,8 +208,8 @@ static struct menu_item* add_shell_item(struct menu_item* parent, LPITEMIDLIST p if (item->folder && shell_folder_is_empty(item->folder)) { IShellFolder_Release(item->folder); - HeapFree(GetProcessHeap(), 0, item->displayname); - HeapFree(GetProcessHeap(), 0, item); + free( item->displayname ); + free( item ); CoTaskMemFree(pidl); return NULL; } @@ -303,8 +303,8 @@ static struct menu_item* add_shell_item(struct menu_item* parent, LPITEMIDLIST p } else { /* duplicate shortcut, do nothing */ - HeapFree(GetProcessHeap(), 0, item->displayname); - HeapFree(GetProcessHeap(), 0, item); + free( item->displayname ); + free( item ); CoTaskMemFree(pidl); item = NULL; } @@ -350,7 +350,7 @@ static void destroy_menus(void) CoTaskMemFree(item->displayname);
list_remove(&item->entry); - HeapFree(GetProcessHeap(), 0, item); + free( item ); } }
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 5070e123829..4cea6c9f458 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -327,9 +327,7 @@ static BOOL show_icon(struct icon *icon) { unsigned int new_count = max( alloc_displayed * 2, 32 ); struct icon **ptr; - if (displayed) ptr = HeapReAlloc( GetProcessHeap(), 0, displayed, new_count * sizeof(*ptr) ); - else ptr = HeapAlloc( GetProcessHeap(), 0, new_count * sizeof(*ptr) ); - if (!ptr) return FALSE; + if (!(ptr = realloc( displayed, new_count * sizeof(*ptr) ))) return FALSE; displayed = ptr; alloc_displayed = new_count; } @@ -433,7 +431,7 @@ static BOOL add_icon(NOTIFYICONDATAW *nid) return FALSE; }
- if (!(icon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*icon)))) + if (!(icon = calloc( 1, sizeof(*icon) ))) { WINE_ERR("out of memory\n"); return FALSE; @@ -455,7 +453,7 @@ static BOOL delete_icon(struct icon *icon) hide_icon(icon); list_remove(&icon->entry); DestroyIcon(icon->image); - HeapFree(GetProcessHeap(), 0, icon); + free( icon ); return TRUE; }
@@ -615,7 +613,7 @@ static void add_taskbar_button( HWND hwnd ) if (!GetWindowThreadProcessId( hwnd, &process ) || process == GetCurrentProcessId()) return; }
- if (!(win = HeapAlloc( GetProcessHeap(), 0, sizeof(*win) ))) return; + if (!(win = malloc( sizeof(*win) ))) return; win->hwnd = hwnd; win->button = CreateWindowW( WC_BUTTONW, NULL, WS_CHILD | BS_OWNERDRAW, 0, 0, 0, 0, tray_window, (HMENU)hwnd, 0, 0 ); @@ -639,7 +637,7 @@ static void remove_taskbar_button( HWND hwnd ) if (!win) return; list_remove( &win->entry ); DestroyWindow( win->button ); - HeapFree( GetProcessHeap(), 0, win ); + free( win ); }
static void paint_taskbar_button( const DRAWITEMSTRUCT *dis )