Commit 38898e93 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comdlg32: Use memory allocation helpers.

parent 402fce15
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "commdlg.h" #include "commdlg.h"
#include "cderr.h" #include "cderr.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg); WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
...@@ -128,16 +129,17 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved) ...@@ -128,16 +129,17 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
* Success: Pointer to a heap block * Success: Pointer to a heap block
* Failure: null * Failure: null
*/ */
LPVOID COMDLG32_AllocMem( void *COMDLG32_AllocMem(int size)
int size /* [in] Block size to allocate */ {
) { void *ptr = heap_alloc_zero(size);
LPVOID ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if(!ptr) if (!ptr)
{ {
COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE); COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
return NULL; return NULL;
} }
return ptr;
return ptr;
} }
......
...@@ -31,10 +31,12 @@ ...@@ -31,10 +31,12 @@
#include "winuser.h" #include "winuser.h"
#include "commdlg.h" #include "commdlg.h"
#include "dlgs.h" #include "dlgs.h"
#include "wine/debug.h"
#include "cderr.h" #include "cderr.h"
#include "cdlg.h" #include "cdlg.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg); WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
static INT_PTR CALLBACK ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ); static INT_PTR CALLBACK ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam );
...@@ -858,7 +860,7 @@ static LRESULT CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam ) ...@@ -858,7 +860,7 @@ static LRESULT CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
return FALSE; return FALSE;
} }
lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) ); lpp = heap_alloc_zero(sizeof(*lpp));
lpp->lpcc = cc; lpp->lpcc = cc;
lpp->hwndSelf = hDlg; lpp->hwndSelf = hDlg;
...@@ -1215,7 +1217,7 @@ static INT_PTR CALLBACK ColorDlgProc( HWND hDlg, UINT message, ...@@ -1215,7 +1217,7 @@ static INT_PTR CALLBACK ColorDlgProc( HWND hDlg, UINT message,
case WM_NCDESTROY: case WM_NCDESTROY:
DeleteDC(lpp->hdcMem); DeleteDC(lpp->hdcMem);
DeleteObject(lpp->hbmMem); DeleteObject(lpp->hbmMem);
HeapFree(GetProcessHeap(), 0, lpp); heap_free(lpp);
RemovePropW( hDlg, szColourDialogProp ); RemovePropW( hDlg, szColourDialogProp );
break; break;
case WM_COMMAND: case WM_COMMAND:
...@@ -1326,7 +1328,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol ) ...@@ -1326,7 +1328,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
LPWSTR template_name = NULL; LPWSTR template_name = NULL;
BOOL ret; BOOL ret;
LPCHOOSECOLORW lpcc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW)); CHOOSECOLORW *lpcc = heap_alloc_zero(sizeof(*lpcc));
lpcc->lStructSize = sizeof(*lpcc); lpcc->lStructSize = sizeof(*lpcc);
lpcc->hwndOwner = lpChCol->hwndOwner; lpcc->hwndOwner = lpChCol->hwndOwner;
lpcc->hInstance = lpChCol->hInstance; lpcc->hInstance = lpChCol->hInstance;
...@@ -1338,7 +1340,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol ) ...@@ -1338,7 +1340,7 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) { if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
if (!IS_INTRESOURCE(lpChCol->lpTemplateName)) { if (!IS_INTRESOURCE(lpChCol->lpTemplateName)) {
INT len = MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, NULL, 0); INT len = MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, NULL, 0);
template_name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); template_name = heap_alloc( len * sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, template_name, len ); MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, template_name, len );
lpcc->lpTemplateName = template_name; lpcc->lpTemplateName = template_name;
} else { } else {
...@@ -1350,7 +1352,8 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol ) ...@@ -1350,7 +1352,8 @@ BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
if (ret) if (ret)
lpChCol->rgbResult = lpcc->rgbResult; lpChCol->rgbResult = lpcc->rgbResult;
HeapFree(GetProcessHeap(), 0, template_name);
HeapFree(GetProcessHeap(), 0, lpcc); heap_free(template_name);
heap_free(lpcc);
return ret; return ret;
} }
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg); WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
...@@ -236,10 +237,6 @@ static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl); ...@@ -236,10 +237,6 @@ static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
static UINT GetNumSelected( IDataObject *doSelected ); static UINT GetNumSelected( IDataObject *doSelected );
static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium); static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
/* Shell memory allocation */
static void *MemAlloc(UINT size);
static void MemFree(void *mem);
static INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static INT_PTR CALLBACK FileOpenDlgProc95(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static INT_PTR FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed); static BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPWSTR lpstrFileList, UINT nFileCount, UINT sizeUsed);
...@@ -349,7 +346,7 @@ static WCHAR *heap_strdupAtoW(const char *str) ...@@ -349,7 +346,7 @@ static WCHAR *heap_strdupAtoW(const char *str)
return NULL; return NULL;
len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0); len = MultiByteToWideChar(CP_ACP, 0, str, -1, 0, 0);
ret = MemAlloc(len * sizeof(WCHAR)); ret = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
return ret; return ret;
...@@ -379,7 +376,7 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info) ...@@ -379,7 +376,7 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
if (ofn->lpstrFile) if (ofn->lpstrFile)
{ {
info->filename = MemAlloc(ofn->nMaxFile * sizeof(WCHAR)); info->filename = heap_alloc(ofn->nMaxFile * sizeof(WCHAR));
lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile); lstrcpynW(info->filename, ofn->lpstrFile, ofn->nMaxFile);
} }
...@@ -388,7 +385,7 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info) ...@@ -388,7 +385,7 @@ static void init_filedlg_infoW(OPENFILENAMEW *ofn, FileOpenDlgInfos *info)
DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0); DWORD len = ExpandEnvironmentStringsW(ofn->lpstrInitialDir, NULL, 0);
if (len) if (len)
{ {
info->initdir = MemAlloc(len * sizeof(WCHAR)); info->initdir = heap_alloc(len * sizeof(WCHAR));
ExpandEnvironmentStringsW(ofn->lpstrInitialDir, info->initdir, len); ExpandEnvironmentStringsW(ofn->lpstrInitialDir, info->initdir, len);
} }
} }
...@@ -410,7 +407,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info) ...@@ -410,7 +407,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
if (ofn->lpstrFile) if (ofn->lpstrFile)
{ {
len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, NULL, 0);
ofnW.lpstrFile = MemAlloc(len * sizeof(WCHAR)); ofnW.lpstrFile = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len); MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFile, ofn->nMaxFile, ofnW.lpstrFile, len);
ofnW.nMaxFile = len; ofnW.nMaxFile = len;
} }
...@@ -426,7 +423,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info) ...@@ -426,7 +423,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
s++; s++;
n = s - ofn->lpstrFilter; n = s - ofn->lpstrFilter;
len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0);
ofnW.lpstrFilter = MemAlloc(len * sizeof(WCHAR)); ofnW.lpstrFilter = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, (WCHAR *)ofnW.lpstrFilter, len); MultiByteToWideChar(CP_ACP, 0, ofn->lpstrFilter, n, (WCHAR *)ofnW.lpstrFilter, len);
} }
...@@ -442,7 +439,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info) ...@@ -442,7 +439,7 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
if (*s) s = s+strlen(s)+1; if (*s) s = s+strlen(s)+1;
n = s - ofn->lpstrCustomFilter; n = s - ofn->lpstrCustomFilter;
len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0);
ofnW.lpstrCustomFilter = MemAlloc(len * sizeof(WCHAR)); ofnW.lpstrCustomFilter = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, ofnW.lpstrCustomFilter, len); MultiByteToWideChar(CP_ACP, 0, ofn->lpstrCustomFilter, n, ofnW.lpstrCustomFilter, len);
} }
...@@ -453,8 +450,8 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info) ...@@ -453,8 +450,8 @@ static void init_filedlg_infoA(OPENFILENAMEA *ofn, FileOpenDlgInfos *info)
info->unicode = FALSE; info->unicode = FALSE;
/* free what was duplicated */ /* free what was duplicated */
MemFree((WCHAR *)ofnW.lpstrInitialDir); heap_free((void *)ofnW.lpstrInitialDir);
MemFree((WCHAR *)ofnW.lpstrFile); heap_free(ofnW.lpstrFile);
} }
/*********************************************************************** /***********************************************************************
...@@ -470,7 +467,7 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type) ...@@ -470,7 +467,7 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
/* save current directory */ /* save current directory */
if (info->ofnInfos->Flags & OFN_NOCHANGEDIR) if (info->ofnInfos->Flags & OFN_NOCHANGEDIR)
{ {
current_dir = MemAlloc(MAX_PATH * sizeof(WCHAR)); current_dir = heap_alloc(MAX_PATH * sizeof(WCHAR));
GetCurrentDirectoryW(MAX_PATH, current_dir); GetCurrentDirectoryW(MAX_PATH, current_dir);
} }
...@@ -490,19 +487,19 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type) ...@@ -490,19 +487,19 @@ static BOOL GetFileDialog95(FileOpenDlgInfos *info, UINT dlg_type)
if (current_dir) if (current_dir)
{ {
SetCurrentDirectoryW(current_dir); SetCurrentDirectoryW(current_dir);
MemFree(current_dir); heap_free(current_dir);
} }
if (!info->unicode) if (!info->unicode)
{ {
MemFree((WCHAR *)info->defext); heap_free((void *)info->defext);
MemFree((WCHAR *)info->title); heap_free((void *)info->title);
MemFree((WCHAR *)info->filter); heap_free((void *)info->filter);
MemFree((WCHAR *)info->customfilter); heap_free((void *)info->customfilter);
} }
MemFree(info->filename); heap_free(info->filename);
MemFree(info->initdir); heap_free(info->initdir);
return ret; return ret;
} }
...@@ -580,7 +577,7 @@ int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileLis ...@@ -580,7 +577,7 @@ int COMDLG32_SplitFileNames(LPWSTR lpstrEdit, UINT nStrLen, LPWSTR *lpstrFileLis
/* we might get single filename without any '"', /* we might get single filename without any '"',
* so we need nStrLen + terminating \0 + end-of-list \0 */ * so we need nStrLen + terminating \0 + end-of-list \0 */
*lpstrFileList = MemAlloc( (nStrLen+2)*sizeof(WCHAR) ); *lpstrFileList = heap_alloc((nStrLen + 2) * sizeof(WCHAR));
*sizeUsed = 0; *sizeUsed = 0;
/* build delimited file list from filenames */ /* build delimited file list from filenames */
...@@ -908,7 +905,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result ...@@ -908,7 +905,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result
/* get path and filenames */ /* get path and filenames */
len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 ); len = SendMessageW( fodInfos->DlgInfos.hwndFileName, WM_GETTEXTLENGTH, 0, 0 );
buffer = HeapAlloc( GetProcessHeap(), 0, (len + 2 + MAX_PATH) * sizeof(WCHAR) ); buffer = heap_alloc( (len + 2 + MAX_PATH) * sizeof(WCHAR) );
COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer ); COMDLG32_GetDisplayNameOf( fodInfos->ShellInfos.pidlAbsCurrent, buffer );
if (len) if (len)
{ {
...@@ -928,7 +925,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result ...@@ -928,7 +925,7 @@ static INT_PTR FILEDLG95_Handle_GetFilePath(HWND hwnd, DWORD size, LPVOID result
if (total <= size) WideCharToMultiByte( CP_ACP, 0, buffer, -1, result, size, NULL, NULL ); if (total <= size) WideCharToMultiByte( CP_ACP, 0, buffer, -1, result, size, NULL, NULL );
TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_a(result)); TRACE( "CDM_GETFILEPATH: returning %u %s\n", total, debugstr_a(result));
} }
HeapFree( GetProcessHeap(), 0, buffer ); heap_free( buffer );
return total; return total;
} }
...@@ -1589,8 +1586,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1589,8 +1586,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
else else
*fodInfos->filename = '\0'; *fodInfos->filename = '\0';
MemFree(fodInfos->initdir); heap_free(fodInfos->initdir);
fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR)); fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf) + 1)*sizeof(WCHAR));
lstrcpyW(fodInfos->initdir, tmpBuf); lstrcpyW(fodInfos->initdir, tmpBuf);
handledPath = TRUE; handledPath = TRUE;
TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n", TRACE("Value in Filename includes path, overriding InitialDir: %s, %s\n",
...@@ -1624,8 +1621,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1624,8 +1621,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit); result = GetFullPathNameW(tmpBuf, MAX_PATH, tmpBuf2, &nameBit);
if (result) { if (result) {
*nameBit = 0x00; *nameBit = 0x00;
MemFree(fodInfos->initdir); heap_free(fodInfos->initdir);
fodInfos->initdir = MemAlloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR)); fodInfos->initdir = heap_alloc((lstrlenW(tmpBuf2) + 1) * sizeof(WCHAR));
lstrcpyW(fodInfos->initdir, tmpBuf2); lstrcpyW(fodInfos->initdir, tmpBuf2);
handledPath = TRUE; handledPath = TRUE;
TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir)); TRACE("Value in InitDir changed to %s\n", debugstr_w(fodInfos->initdir));
...@@ -1633,7 +1630,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1633,7 +1630,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
} }
else if (fodInfos->initdir) else if (fodInfos->initdir)
{ {
MemFree(fodInfos->initdir); heap_free(fodInfos->initdir);
fodInfos->initdir = NULL; fodInfos->initdir = NULL;
TRACE("Value in InitDir is not an existing path, changed to (nil)\n"); TRACE("Value in InitDir is not an existing path, changed to (nil)\n");
} }
...@@ -1659,8 +1656,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1659,8 +1656,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
*nameBit = 0x00; *nameBit = 0x00;
len = lstrlenW(tmpBuf); len = lstrlenW(tmpBuf);
MemFree(fodInfos->initdir); heap_free(fodInfos->initdir);
fodInfos->initdir = MemAlloc((len+1)*sizeof(WCHAR)); fodInfos->initdir = heap_alloc((len+1)*sizeof(WCHAR));
lstrcpyW(fodInfos->initdir, tmpBuf); lstrcpyW(fodInfos->initdir, tmpBuf);
handledPath = TRUE; handledPath = TRUE;
...@@ -1672,7 +1669,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1672,7 +1669,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
/* 4. Win2000+: Recently used */ /* 4. Win2000+: Recently used */
if (!handledPath && win2000plus) { if (!handledPath && win2000plus) {
fodInfos->initdir = MemAlloc(MAX_PATH * sizeof(WCHAR)); fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
fodInfos->initdir[0] = '\0'; fodInfos->initdir[0] = '\0';
FILEDLG95_MRU_load_filename(fodInfos->initdir); FILEDLG95_MRU_load_filename(fodInfos->initdir);
...@@ -1680,7 +1677,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1680,7 +1677,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
if (fodInfos->initdir[0] && PathFileExistsW(fodInfos->initdir)){ if (fodInfos->initdir[0] && PathFileExistsW(fodInfos->initdir)){
handledPath = TRUE; handledPath = TRUE;
}else{ }else{
MemFree(fodInfos->initdir); heap_free(fodInfos->initdir);
fodInfos->initdir = NULL; fodInfos->initdir = NULL;
} }
} }
...@@ -1712,8 +1709,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1712,8 +1709,8 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
} else { } else {
MemFree(fodInfos->initdir); heap_free(fodInfos->initdir);
fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR)); fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir); GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
handledPath = TRUE; handledPath = TRUE;
...@@ -1727,7 +1724,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1727,7 +1724,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
/* 6. Win98+ and 2000+: Use personal files dir, others use current dir */ /* 6. Win98+ and 2000+: Use personal files dir, others use current dir */
if (!handledPath && (win2000plus || win98plus)) { if (!handledPath && (win2000plus || win98plus)) {
fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR)); fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
if(!COMDLG32_SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir)) if(!COMDLG32_SHGetFolderPathW(hwnd, CSIDL_PERSONAL, 0, 0, fodInfos->initdir))
{ {
...@@ -1744,7 +1741,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd) ...@@ -1744,7 +1741,7 @@ static LRESULT FILEDLG95_InitControls(HWND hwnd)
} }
handledPath = TRUE; handledPath = TRUE;
} else if (!handledPath) { } else if (!handledPath) {
fodInfos->initdir = MemAlloc(MAX_PATH*sizeof(WCHAR)); fodInfos->initdir = heap_alloc(MAX_PATH * sizeof(WCHAR));
GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir); GetCurrentDirectoryW(MAX_PATH, fodInfos->initdir);
handledPath = TRUE; handledPath = TRUE;
TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir)); TRACE("No initial dir specified, using current dir of %s\n", debugstr_w(fodInfos->initdir));
...@@ -2264,7 +2261,7 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename) ...@@ -2264,7 +2261,7 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
final_len = path_len + lstrlenW(module_name) + 2; final_len = path_len + lstrlenW(module_name) + 2;
final = MemAlloc(final_len * sizeof(WCHAR)); final = heap_alloc(final_len * sizeof(WCHAR));
if(!final) if(!final)
return; return;
lstrcpyW(final, module_name); lstrcpyW(final, module_name);
...@@ -2275,12 +2272,12 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename) ...@@ -2275,12 +2272,12 @@ static void FILEDLG95_MRU_save_filename(LPCWSTR filename)
final_len * sizeof(WCHAR)); final_len * sizeof(WCHAR));
if(ret){ if(ret){
WARN("Error saving MRU data to slot %s: %d\n", wine_dbgstr_w(slot_name), ret); WARN("Error saving MRU data to slot %s: %d\n", wine_dbgstr_w(slot_name), ret);
MemFree(final); heap_free(final);
RegCloseKey(hkey); RegCloseKey(hkey);
return; return;
} }
MemFree(final); heap_free(final);
} }
{ /* update MRUList value */ { /* update MRUList value */
...@@ -2517,7 +2514,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2517,7 +2514,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
*/ */
COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile); COMDLG32_GetCanonicalPath(fodInfos->ShellInfos.pidlAbsCurrent, lpstrFileList, lpstrPathAndFile);
MemFree(lpstrFileList); heap_free(lpstrFileList);
/* /*
Step 2: here we have a cleaned up path Step 2: here we have a cleaned up path
...@@ -2564,9 +2561,9 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2564,9 +2561,9 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
DWORD len; DWORD len;
/* replace the current filter */ /* replace the current filter */
MemFree(fodInfos->ShellInfos.lpstrCurrentFilter); heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
len = lstrlenW(lpszTemp)+1; len = lstrlenW(lpszTemp)+1;
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc(len * sizeof(WCHAR)); fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc(len * sizeof(WCHAR));
lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp); lstrcpyW( fodInfos->ShellInfos.lpstrCurrentFilter, lpszTemp);
/* set the filter cb to the extension when possible */ /* set the filter cb to the extension when possible */
...@@ -2641,7 +2638,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2641,7 +2638,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */ if (lpstrFilter != (LPWSTR)CB_ERR) /* control is not empty */
{ {
WCHAR* filterSearchIndex; WCHAR* filterSearchIndex;
filterExt = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR)); filterExt = heap_alloc((lstrlenW(lpstrFilter) + 1) * sizeof(WCHAR));
strcpyW(filterExt, lpstrFilter); strcpyW(filterExt, lpstrFilter);
/* if a semicolon-separated list of file extensions was given, do not include the /* if a semicolon-separated list of file extensions was given, do not include the
...@@ -2663,7 +2660,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2663,7 +2660,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
} }
else else
{ {
HeapFree(GetProcessHeap(), 0, filterExt); heap_free(filterExt);
filterExt = NULL; filterExt = NULL;
} }
} }
...@@ -2671,7 +2668,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2671,7 +2668,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
if (!filterExt) if (!filterExt)
{ {
/* use the default file extension */ /* use the default file extension */
filterExt = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR)); filterExt = heap_alloc((lstrlenW(fodInfos->defext) + 1) * sizeof(WCHAR));
strcpyW(filterExt, fodInfos->defext); strcpyW(filterExt, fodInfos->defext);
} }
...@@ -2683,7 +2680,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd) ...@@ -2683,7 +2680,7 @@ BOOL FILEDLG95_OnOpen(HWND hwnd)
lstrcatW(lpstrPathAndFile, filterExt); lstrcatW(lpstrPathAndFile, filterExt);
} }
HeapFree(GetProcessHeap(), 0, filterExt); heap_free(filterExt);
/* In Open dialog: if file does not exist try without extension */ /* In Open dialog: if file does not exist try without extension */
if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile)) if (!(fodInfos->DlgInfos.dwDlgProp & FODPROP_SAVEDLG) && !PathFileExistsW(lpstrPathAndFile))
...@@ -2996,7 +2993,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) ...@@ -2996,7 +2993,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
/* Copy the extensions */ /* Copy the extensions */
if (! *lpstrPos) return E_FAIL; /* malformed filter */ if (! *lpstrPos) return E_FAIL; /* malformed filter */
if (!(lpstrExt = MemAlloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL; if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
lstrcpyW(lpstrExt,lpstrPos); lstrcpyW(lpstrExt,lpstrPos);
/* Add the item at the end of the combo */ /* Add the item at the end of the combo */
...@@ -3027,7 +3024,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) ...@@ -3027,7 +3024,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
nFilters++; nFilters++;
/* Copy the extensions */ /* Copy the extensions */
if (!(lpstrExt = MemAlloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL; if (!(lpstrExt = heap_alloc((lstrlenW(lpstrPos)+1)*sizeof(WCHAR)))) return E_FAIL;
lstrcpyW(lpstrExt,lpstrPos); lstrcpyW(lpstrExt,lpstrPos);
lpstrPos += lstrlenW(lpstrPos) + 1; lpstrPos += lstrlenW(lpstrPos) + 1;
...@@ -3076,7 +3073,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) ...@@ -3076,7 +3073,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd)
DWORD len; DWORD len;
CharLowerW(lpstrFilter); /* lowercase */ CharLowerW(lpstrFilter); /* lowercase */
len = lstrlenW(lpstrFilter)+1; len = lstrlenW(lpstrFilter)+1;
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) ); fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter); lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
} }
} else } else
...@@ -3108,7 +3105,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode) ...@@ -3108,7 +3105,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
(fodInfos->customfilter == NULL ? 1 : 0); (fodInfos->customfilter == NULL ? 1 : 0);
/* Set the current filter with the current selection */ /* Set the current filter with the current selection */
MemFree(fodInfos->ShellInfos.lpstrCurrentFilter); heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB, lpstrFilter = (LPWSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,
iItem); iItem);
...@@ -3117,7 +3114,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode) ...@@ -3117,7 +3114,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode)
DWORD len; DWORD len;
CharLowerW(lpstrFilter); /* lowercase */ CharLowerW(lpstrFilter); /* lowercase */
len = lstrlenW(lpstrFilter)+1; len = lstrlenW(lpstrFilter)+1;
fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc( len * sizeof(WCHAR) ); fodInfos->ShellInfos.lpstrCurrentFilter = heap_alloc( len * sizeof(WCHAR) );
lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter); lstrcpyW(fodInfos->ShellInfos.lpstrCurrentFilter,lpstrFilter);
if(fodInfos->ofnInfos->Flags & OFN_EXPLORER) if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)
SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE); SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE);
...@@ -3170,13 +3167,12 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd) ...@@ -3170,13 +3167,12 @@ static void FILEDLG95_FILETYPE_Clean(HWND hwnd)
{ {
for(iPos = iCount-1;iPos>=0;iPos--) for(iPos = iCount-1;iPos>=0;iPos--)
{ {
MemFree((LPSTR) CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos)); heap_free((void *)CBGetItemDataPtr(fodInfos->DlgInfos.hwndFileTypeCB,iPos));
CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos); CBDeleteString(fodInfos->DlgInfos.hwndFileTypeCB,iPos);
} }
} }
/* Current filter */ /* Current filter */
MemFree(fodInfos->ShellInfos.lpstrCurrentFilter); heap_free(fodInfos->ShellInfos.lpstrCurrentFilter);
} }
/*********************************************************************** /***********************************************************************
...@@ -3212,7 +3208,7 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo) ...@@ -3212,7 +3208,7 @@ static void FILEDLG95_LOOKIN_Init(HWND hwndCombo)
LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp; LPITEMIDLIST pidlDrives, pidlTmp, pidlTmp1, pidlAbsTmp;
HDC hdc; HDC hdc;
TEXTMETRICW tm; TEXTMETRICW tm;
LookInInfos *liInfos = MemAlloc(sizeof(LookInInfos)); LookInInfos *liInfos = heap_alloc_zero(sizeof(*liInfos));
TRACE("%p\n", hwndCombo); TRACE("%p\n", hwndCombo);
...@@ -3441,7 +3437,7 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId) ...@@ -3441,7 +3437,7 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
if(!(liInfos = GetPropA(hwnd,LookInInfosStr))) if(!(liInfos = GetPropA(hwnd,LookInInfosStr)))
return -1; return -1;
tmpFolder = MemAlloc(sizeof(SFOLDER)); tmpFolder = heap_alloc_zero(sizeof(*tmpFolder));
tmpFolder->m_iIndent = 0; tmpFolder->m_iIndent = 0;
/* Calculate the indentation of the item in the lookin*/ /* Calculate the indentation of the item in the lookin*/
...@@ -3487,7 +3483,7 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId) ...@@ -3487,7 +3483,7 @@ static int FILEDLG95_LOOKIN_AddItem(HWND hwnd,LPITEMIDLIST pidl, int iInsertId)
} }
COMDLG32_SHFree( tmpFolder->pidlItem ); COMDLG32_SHFree( tmpFolder->pidlItem );
MemFree( tmpFolder ); heap_free( tmpFolder );
return -1; return -1;
} }
...@@ -3584,7 +3580,7 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd) ...@@ -3584,7 +3580,7 @@ static int FILEDLG95_LOOKIN_RemoveMostExpandedItem(HWND hwnd)
{ {
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos); SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(hwnd,iItemPos);
COMDLG32_SHFree(tmpFolder->pidlItem); COMDLG32_SHFree(tmpFolder->pidlItem);
MemFree(tmpFolder); heap_free(tmpFolder);
CBDeleteString(hwnd,iItemPos); CBDeleteString(hwnd,iItemPos);
liInfos->iMaxIndentation--; liInfos->iMaxIndentation--;
...@@ -3644,13 +3640,13 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd) ...@@ -3644,13 +3640,13 @@ static void FILEDLG95_LOOKIN_Clean(HWND hwnd)
{ {
SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos); SFOLDER *tmpFolder = (LPSFOLDER) CBGetItemDataPtr(fodInfos->DlgInfos.hwndLookInCB,iPos);
COMDLG32_SHFree(tmpFolder->pidlItem); COMDLG32_SHFree(tmpFolder->pidlItem);
MemFree(tmpFolder); heap_free(tmpFolder);
CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos); CBDeleteString(fodInfos->DlgInfos.hwndLookInCB,iPos);
} }
} }
/* LookInInfos structure */ /* LookInInfos structure */
MemFree(liInfos); heap_free(liInfos);
RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr); RemovePropA(fodInfos->DlgInfos.hwndLookInCB,LookInInfosStr);
} }
...@@ -3698,7 +3694,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) ...@@ -3698,7 +3694,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
/* Allocate a buffer */ /* Allocate a buffer */
nAllFilesMaxLength = MAX_PATH + 3; nAllFilesMaxLength = MAX_PATH + 3;
lpstrAllFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nAllFilesMaxLength * sizeof(WCHAR)); lpstrAllFiles = heap_alloc_zero(nAllFilesMaxLength * sizeof(WCHAR));
if (!lpstrAllFiles) if (!lpstrAllFiles)
goto ret; goto ret;
...@@ -3745,7 +3741,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd) ...@@ -3745,7 +3741,7 @@ void FILEDLG95_FILENAME_FillFromSelection (HWND hwnd)
} }
ret: ret:
HeapFree(GetProcessHeap(), 0, lpstrAllFiles); heap_free(lpstrAllFiles);
COMCTL32_ReleaseStgMedium(medium); COMCTL32_ReleaseStgMedium(medium);
} }
...@@ -3797,13 +3793,13 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U ...@@ -3797,13 +3793,13 @@ static int FILEDLG95_FILENAME_GetFileNames (HWND hwnd, LPWSTR * lpstrFileList, U
/* get the filenames from the filename control */ /* get the filenames from the filename control */
nStrLen = GetWindowTextLengthW( fodInfos->DlgInfos.hwndFileName ); nStrLen = GetWindowTextLengthW( fodInfos->DlgInfos.hwndFileName );
lpstrEdit = MemAlloc( (nStrLen+1)*sizeof(WCHAR) ); lpstrEdit = heap_alloc( (nStrLen+1)*sizeof(WCHAR) );
GetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrEdit, nStrLen+1); GetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrEdit, nStrLen+1);
TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit)); TRACE("nStrLen=%u str=%s\n", nStrLen, debugstr_w(lpstrEdit));
nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed); nFileCount = COMDLG32_SplitFileNames(lpstrEdit, nStrLen, lpstrFileList, sizeUsed);
MemFree(lpstrEdit); heap_free(lpstrEdit);
return nFileCount; return nFileCount;
} }
...@@ -4052,18 +4048,6 @@ static BOOL BrowseSelectedFolder(HWND hwnd) ...@@ -4052,18 +4048,6 @@ static BOOL BrowseSelectedFolder(HWND hwnd)
return bBrowseSelFolder; return bBrowseSelFolder;
} }
/*
* Memory allocation methods */
static void *MemAlloc(UINT size)
{
return HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,size);
}
static void MemFree(void *mem)
{
HeapFree(GetProcessHeap(),0,mem);
}
static inline BOOL valid_struct_size( DWORD size ) static inline BOOL valid_struct_size( DWORD size )
{ {
return (size == OPENFILENAME_SIZE_VERSION_400W) || return (size == OPENFILENAME_SIZE_VERSION_400W) ||
...@@ -4220,11 +4204,11 @@ short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf) ...@@ -4220,11 +4204,11 @@ short WINAPI GetFileTitleA(LPCSTR lpFile, LPSTR lpTitle, WORD cbBuf)
LPWSTR lpWTitle; LPWSTR lpWTitle;
RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile); RtlCreateUnicodeStringFromAsciiz(&strWFile, lpFile);
lpWTitle = RtlAllocateHeap( GetProcessHeap(), 0, cbBuf*sizeof(WCHAR)); lpWTitle = heap_alloc(cbBuf * sizeof(WCHAR));
ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf); ret = GetFileTitleW(strWFile.Buffer, lpWTitle, cbBuf);
if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL ); if (!ret) WideCharToMultiByte( CP_ACP, 0, lpWTitle, -1, lpTitle, cbBuf, NULL, NULL );
RtlFreeUnicodeString( &strWFile ); RtlFreeUnicodeString( &strWFile );
RtlFreeHeap( GetProcessHeap(), 0, lpWTitle ); heap_free( lpWTitle );
return ret; return ret;
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "winuser.h" #include "winuser.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "winreg.h" #include "winreg.h"
#include "winternl.h" #include "winternl.h"
#include "commdlg.h" #include "commdlg.h"
...@@ -231,7 +232,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam, ...@@ -231,7 +232,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1) if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
{ {
if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) return FALSE; if (!(str = heap_alloc(BUFFILEALLOC))) return FALSE;
SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
(LPARAM)str); (LPARAM)str);
...@@ -255,13 +256,13 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam, ...@@ -255,13 +256,13 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
SetBkColor( lpdis->hDC, oldBk ); SetBkColor( lpdis->hDC, oldBk );
SetTextColor( lpdis->hDC, oldText ); SetTextColor( lpdis->hDC, oldText );
} }
HeapFree(GetProcessHeap(), 0, str); heap_free(str);
return TRUE; return TRUE;
} }
if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2) if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
{ {
if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) if (!(str = heap_alloc(BUFFILEALLOC)))
return FALSE; return FALSE;
SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID, SendMessageW(lpdis->hwndItem, LB_GETTEXT, lpdis->itemID,
(LPARAM)str); (LPARAM)str);
...@@ -284,13 +285,13 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam, ...@@ -284,13 +285,13 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
SetTextColor( lpdis->hDC, oldText ); SetTextColor( lpdis->hDC, oldText );
} }
DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder, 16, 16, 0, 0, DI_NORMAL ); DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hFolder, 16, 16, 0, 0, DI_NORMAL );
HeapFree(GetProcessHeap(), 0, str); heap_free(str);
return TRUE; return TRUE;
} }
if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2) if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
{ {
char root[] = "a:"; char root[] = "a:";
if (!(str = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) if (!(str = heap_alloc(BUFFILEALLOC)))
return FALSE; return FALSE;
SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID, SendMessageW(lpdis->hwndItem, CB_GETLBTEXT, lpdis->itemID,
(LPARAM)str); (LPARAM)str);
...@@ -318,7 +319,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam, ...@@ -318,7 +319,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
SetTextColor( lpdis->hDC, oldText ); SetTextColor( lpdis->hDC, oldText );
} }
DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon, 16, 16, 0, 0, DI_NORMAL ); DrawIconEx( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, hIcon, 16, 16, 0, 0, DI_NORMAL );
HeapFree(GetProcessHeap(), 0, str); heap_free(str);
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
...@@ -418,11 +419,11 @@ static LRESULT FD31_DirListDblClick( const FD31_DATA *lfs ) ...@@ -418,11 +419,11 @@ static LRESULT FD31_DirListDblClick( const FD31_DATA *lfs )
/* get the raw string (with brackets) */ /* get the raw string (with brackets) */
lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0); lRet = SendDlgItemMessageW(hWnd, lst2, LB_GETCURSEL, 0, 0);
if (lRet == LB_ERR) return TRUE; if (lRet == LB_ERR) return TRUE;
pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC); pstr = heap_alloc(BUFFILEALLOC);
SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet, SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet,
(LPARAM)pstr); (LPARAM)pstr);
strcpyW( tmpstr, pstr ); strcpyW( tmpstr, pstr );
HeapFree(GetProcessHeap(), 0, pstr); heap_free(pstr);
/* get the selected directory in tmpstr */ /* get the selected directory in tmpstr */
if (tmpstr[0] == '[') if (tmpstr[0] == '[')
{ {
...@@ -457,12 +458,12 @@ static LRESULT FD31_FileListSelect( const FD31_DATA *lfs ) ...@@ -457,12 +458,12 @@ static LRESULT FD31_FileListSelect( const FD31_DATA *lfs )
return TRUE; return TRUE;
/* set the edit control to the chosen file */ /* set the edit control to the chosen file */
if ((pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC))) if ((pstr = heap_alloc(BUFFILEALLOC)))
{ {
SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet, SendDlgItemMessageW(hWnd, lst1, LB_GETTEXT, lRet,
(LPARAM)pstr); (LPARAM)pstr);
SetDlgItemTextW( hWnd, edt1, pstr ); SetDlgItemTextW( hWnd, edt1, pstr );
HeapFree(GetProcessHeap(), 0, pstr); heap_free(pstr);
} }
if (lfs->hook) if (lfs->hook)
{ {
...@@ -624,11 +625,11 @@ static LRESULT FD31_DiskChange( const FD31_DATA *lfs ) ...@@ -624,11 +625,11 @@ static LRESULT FD31_DiskChange( const FD31_DATA *lfs )
lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L); lRet = SendDlgItemMessageW(hWnd, cmb2, CB_GETCURSEL, 0, 0L);
if (lRet == LB_ERR) if (lRet == LB_ERR)
return 0; return 0;
pstr = HeapAlloc(GetProcessHeap(), 0, BUFFILEALLOC); pstr = heap_alloc(BUFFILEALLOC);
SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet, SendDlgItemMessageW(hWnd, cmb2, CB_GETLBTEXT, lRet,
(LPARAM)pstr); (LPARAM)pstr);
wsprintfW(diskname, FILE_specc, pstr[2]); wsprintfW(diskname, FILE_specc, pstr[2]);
HeapFree(GetProcessHeap(), 0, pstr); heap_free(pstr);
return FD31_Validate( lfs, diskname, cmb2, lRet, TRUE ); return FD31_Validate( lfs, diskname, cmb2, lRet, TRUE );
} }
...@@ -729,7 +730,7 @@ static LPWSTR FD31_MapStringPairsToW(LPCSTR strA, UINT size) ...@@ -729,7 +730,7 @@ static LPWSTR FD31_MapStringPairsToW(LPCSTR strA, UINT size)
if (n < size) n = size; if (n < size) n = size;
len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 ); len = MultiByteToWideChar( CP_ACP, 0, strA, n, NULL, 0 );
x = HeapAlloc(GetProcessHeap(),0, len * sizeof(WCHAR)); x = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar( CP_ACP, 0, strA, n, x, len ); MultiByteToWideChar( CP_ACP, 0, strA, n, x, len );
return x; return x;
} }
...@@ -744,7 +745,7 @@ static LPWSTR FD31_DupToW(LPCSTR str, DWORD size) ...@@ -744,7 +745,7 @@ static LPWSTR FD31_DupToW(LPCSTR str, DWORD size)
LPWSTR strW = NULL; LPWSTR strW = NULL;
if (str && (size > 0)) if (str && (size > 0))
{ {
strW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); strW = heap_alloc(size * sizeof(WCHAR));
if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size ); if (strW) MultiByteToWideChar( CP_ACP, 0, str, -1, strW, size );
} }
return strW; return strW;
...@@ -786,7 +787,7 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW, ...@@ -786,7 +787,7 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW,
LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS, LoadStringW(COMDLG32_hInstance, open ? IDS_OPEN_FILE : IDS_SAVE_AS,
buf, sizeof(buf)/sizeof(WCHAR)); buf, sizeof(buf)/sizeof(WCHAR));
len = lstrlenW(buf)+1; len = lstrlenW(buf)+1;
title_tmp = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); title_tmp = heap_alloc(len * sizeof(WCHAR));
memcpy(title_tmp, buf, len * sizeof(WCHAR)); memcpy(title_tmp, buf, len * sizeof(WCHAR));
ofnW->lpstrTitle = title_tmp; ofnW->lpstrTitle = title_tmp;
} }
...@@ -819,14 +820,14 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW, ...@@ -819,14 +820,14 @@ static void FD31_MapOfnStructA(const OPENFILENAMEA *ofnA, LPOPENFILENAMEW ofnW,
*/ */
static void FD31_FreeOfnW(OPENFILENAMEW *ofnW) static void FD31_FreeOfnW(OPENFILENAMEW *ofnW)
{ {
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrFilter); heap_free((void *)ofnW->lpstrFilter);
HeapFree(GetProcessHeap(), 0, ofnW->lpstrCustomFilter); heap_free(ofnW->lpstrCustomFilter);
HeapFree(GetProcessHeap(), 0, ofnW->lpstrFile); heap_free(ofnW->lpstrFile);
HeapFree(GetProcessHeap(), 0, ofnW->lpstrFileTitle); heap_free(ofnW->lpstrFileTitle);
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrInitialDir); heap_free((void *)ofnW->lpstrInitialDir);
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpstrTitle); heap_free((void *)ofnW->lpstrTitle);
if (!IS_INTRESOURCE(ofnW->lpTemplateName)) if (!IS_INTRESOURCE(ofnW->lpTemplateName))
HeapFree(GetProcessHeap(), 0, (LPWSTR) ofnW->lpTemplateName); heap_free((void *)ofnW->lpTemplateName);
} }
/************************************************************************ /************************************************************************
...@@ -844,9 +845,9 @@ static void FD31_DestroyPrivate(PFD31_DATA lfs) ...@@ -844,9 +845,9 @@ static void FD31_DestroyPrivate(PFD31_DATA lfs)
if (lfs->ofnA) if (lfs->ofnA)
{ {
FD31_FreeOfnW(lfs->ofnW); FD31_FreeOfnW(lfs->ofnW);
HeapFree(GetProcessHeap(), 0, lfs->ofnW); heap_free(lfs->ofnW);
} }
HeapFree(GetProcessHeap(), 0, lfs); heap_free(lfs);
RemovePropA(hwnd, FD31_OFN_PROP); RemovePropA(hwnd, FD31_OFN_PROP);
} }
...@@ -918,7 +919,7 @@ static BOOL FD31_GetTemplate(PFD31_DATA lfs) ...@@ -918,7 +919,7 @@ static BOOL FD31_GetTemplate(PFD31_DATA lfs)
*/ */
static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode) static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
{ {
PFD31_DATA lfs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FD31_DATA)); FD31_DATA *lfs = heap_alloc_zero(sizeof(*lfs));
TRACE("alloc private buf %p\n", lfs); TRACE("alloc private buf %p\n", lfs);
if (!lfs) return NULL; if (!lfs) return NULL;
...@@ -940,7 +941,7 @@ static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode) ...@@ -940,7 +941,7 @@ static PFD31_DATA FD31_AllocPrivate(LPARAM lParam, UINT dlgType, BOOL IsUnicode)
if (lfs->ofnA->Flags & OFN_ENABLEHOOK) if (lfs->ofnA->Flags & OFN_ENABLEHOOK)
if (lfs->ofnA->lpfnHook) if (lfs->ofnA->lpfnHook)
lfs->hook = TRUE; lfs->hook = TRUE;
lfs->ofnW = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lfs->ofnA->lStructSize); lfs->ofnW = heap_alloc_zero(lfs->ofnA->lStructSize);
lfs->ofnW->lStructSize = lfs->ofnA->lStructSize; lfs->ofnW->lStructSize = lfs->ofnA->lStructSize;
FD31_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open); FD31_MapOfnStructA(lfs->ofnA, lfs->ofnW, lfs->open);
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "cderr.h" #include "cderr.h"
#include "dlgs.h" #include "dlgs.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(commdlg); WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
...@@ -284,7 +285,7 @@ static INT_PTR CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPA ...@@ -284,7 +285,7 @@ static INT_PTR CALLBACK COMDLG32_FindReplaceDlgProc(HWND hDlgWnd, UINT iMsg, WPA
if(iMsg == WM_DESTROY) if(iMsg == WM_DESTROY)
{ {
RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom); RemovePropA(hDlgWnd, (LPSTR)COMDLG32_Atom);
HeapFree(GetProcessHeap(), 0, pdata); heap_free(pdata);
} }
return retval; return retval;
...@@ -427,7 +428,7 @@ static HWND COMDLG32_FR_DoFindReplace( ...@@ -427,7 +428,7 @@ static HWND COMDLG32_FR_DoFindReplace(
error = CDERR_DIALOGFAILURE; error = CDERR_DIALOGFAILURE;
cleanup: cleanup:
COMDLG32_SetCommDlgExtendedError(error); COMDLG32_SetCommDlgExtendedError(error);
HeapFree(GetProcessHeap(), 0, pdata); heap_free(pdata);
} }
return hdlgwnd; return hdlgwnd;
} }
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "commdlg.h" #include "commdlg.h"
#include "dlgs.h" #include "dlgs.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "cderr.h" #include "cderr.h"
#include "cdlg.h" #include "cdlg.h"
...@@ -1151,11 +1152,11 @@ static LRESULT CFn_WMDestroy(HWND hwnd, LPCHOOSEFONTW lpcfw) ...@@ -1151,11 +1152,11 @@ static LRESULT CFn_WMDestroy(HWND hwnd, LPCHOOSEFONTW lpcfw)
if((lpcfw->Flags & CF_USESTYLE) && lpcfw->lpszStyle) { if((lpcfw->Flags & CF_USESTYLE) && lpcfw->lpszStyle) {
len = WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, NULL, 0, 0, 0); len = WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, NULL, 0, 0, 0);
WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, lpcfa->lpszStyle, len, 0, 0); WideCharToMultiByte(CP_ACP, 0, lpcfw->lpszStyle, -1, lpcfa->lpszStyle, len, 0, 0);
HeapFree(GetProcessHeap(), 0, lpcfw->lpszStyle); heap_free(lpcfw->lpszStyle);
} }
HeapFree(GetProcessHeap(), 0, lpcfw->lpLogFont); heap_free(lpcfw->lpLogFont);
HeapFree(GetProcessHeap(), 0, lpcfw); heap_free(lpcfw);
SetPropW(hwnd, strWineFontData, 0); SetPropW(hwnd, strWineFontData, 0);
return TRUE; return TRUE;
...@@ -1217,16 +1218,16 @@ static INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam, ...@@ -1217,16 +1218,16 @@ static INT_PTR CALLBACK FormatCharDlgProcA(HWND hDlg, UINT uMsg, WPARAM wParam,
lpcfa=(LPCHOOSEFONTA)lParam; lpcfa=(LPCHOOSEFONTA)lParam;
SetPropW(hDlg, strWineFontData_a, (HANDLE)lParam); SetPropW(hDlg, strWineFontData_a, (HANDLE)lParam);
lpcfw = HeapAlloc(GetProcessHeap(), 0, sizeof(CHOOSEFONTW)); lpcfw = heap_alloc(sizeof(*lpcfw));
memcpy(lpcfw, lpcfa, sizeof(CHOOSEFONTA)); memcpy(lpcfw, lpcfa, sizeof(CHOOSEFONTA));
lpcfw->lpLogFont = HeapAlloc(GetProcessHeap(), 0, sizeof(LOGFONTW)); lpcfw->lpLogFont = heap_alloc(sizeof(*lpcfw->lpLogFont));
memcpy(lpcfw->lpLogFont, lpcfa->lpLogFont, sizeof(LOGFONTA)); memcpy(lpcfw->lpLogFont, lpcfa->lpLogFont, sizeof(LOGFONTA));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpLogFont->lfFaceName, MultiByteToWideChar(CP_ACP, 0, lpcfa->lpLogFont->lfFaceName,
LF_FACESIZE, lpcfw->lpLogFont->lfFaceName, LF_FACESIZE); LF_FACESIZE, lpcfw->lpLogFont->lfFaceName, LF_FACESIZE);
if((lpcfa->Flags & CF_USESTYLE) && lpcfa->lpszStyle) { if((lpcfa->Flags & CF_USESTYLE) && lpcfa->lpszStyle) {
len = MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, NULL, 0);
lpcfw->lpszStyle = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); lpcfw->lpszStyle = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, lpcfw->lpszStyle, len); MultiByteToWideChar(CP_ACP, 0, lpcfa->lpszStyle, -1, lpcfw->lpszStyle, len);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment