Commit 1f4532d5 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

winecfg: Use standard C functions for memory allocation.

parent a1ffd507
...@@ -64,8 +64,8 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -64,8 +64,8 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
L"RegisteredOrganization", org ? org : L""); L"RegisteredOrganization", org ? org : L"");
apply(); apply();
HeapFree(GetProcessHeap(), 0, owner); free(owner);
HeapFree(GetProcessHeap(), 0, org); free(org);
break; break;
case NM_CLICK: case NM_CLICK:
...@@ -90,8 +90,8 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -90,8 +90,8 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0); SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
HeapFree(GetProcessHeap(), 0, owner); free(owner);
HeapFree(GetProcessHeap(), 0, org); free(org);
/* prepare the panel */ /* prepare the panel */
hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL); hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "wine/heap.h"
#include "winecfg.h" #include "winecfg.h"
#include "resource.h" #include "resource.h"
...@@ -139,7 +138,7 @@ static void update_comboboxes(HWND dialog) ...@@ -139,7 +138,7 @@ static void update_comboboxes(HWND dialog)
if (!winver || !winver[0]) if (!winver || !winver[0])
{ {
HeapFree(GetProcessHeap(), 0, winver); free(winver);
if (current_app) /* no explicit setting */ if (current_app) /* no explicit setting */
{ {
...@@ -147,8 +146,8 @@ static void update_comboboxes(HWND dialog) ...@@ -147,8 +146,8 @@ static void update_comboboxes(HWND dialog)
SendDlgItemMessageW(dialog, IDC_WINVER, CB_SETCURSEL, 0, 0); SendDlgItemMessageW(dialog, IDC_WINVER, CB_SETCURSEL, 0, 0);
return; return;
} }
if (ver != -1) winver = strdupW( win_versions[ver].szVersion ); if (ver != -1) winver = wcsdup(win_versions[ver].szVersion);
else winver = strdupW(DEFAULT_WIN_VERSION); else winver = wcsdup(DEFAULT_WIN_VERSION);
} }
WINE_TRACE("winver is %s\n", debugstr_w(winver)); WINE_TRACE("winver is %s\n", debugstr_w(winver));
...@@ -164,7 +163,7 @@ static void update_comboboxes(HWND dialog) ...@@ -164,7 +163,7 @@ static void update_comboboxes(HWND dialog)
} }
} }
HeapFree(GetProcessHeap(), 0, winver); free(winver);
} }
static void static void
...@@ -229,7 +228,7 @@ static void init_appsheet(HWND dialog) ...@@ -229,7 +228,7 @@ static void init_appsheet(HWND dialog)
size = ARRAY_SIZE(appname); size = ARRAY_SIZE(appname);
while (RegEnumKeyExW (key, i, appname, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) while (RegEnumKeyExW (key, i, appname, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{ {
add_listview_item(listview, appname, strdupW(appname)); add_listview_item(listview, appname, wcsdup(appname));
i++; i++;
size = ARRAY_SIZE(appname); size = ARRAY_SIZE(appname);
...@@ -355,7 +354,7 @@ static void on_add_app_click(HWND dialog) ...@@ -355,7 +354,7 @@ static void on_add_app_click(HWND dialog)
if (list_contains_file(listview, filetitle)) if (list_contains_file(listview, filetitle))
return; return;
new_app = strdupW(filetitle); new_app = wcsdup(filetitle);
WINE_TRACE("adding %s\n", wine_dbgstr_w (new_app)); WINE_TRACE("adding %s\n", wine_dbgstr_w (new_app));
...@@ -387,7 +386,7 @@ static void on_remove_app_click(HWND dialog) ...@@ -387,7 +386,7 @@ static void on_remove_app_click(HWND dialog)
set_reg_key(config_key, keypath(L""), NULL, NULL); /* delete the section */ set_reg_key(config_key, keypath(L""), NULL, NULL); /* delete the section */
SendMessageW(listview, LVM_GETITEMW, 0, (LPARAM) &item); SendMessageW(listview, LVM_GETITEMW, 0, (LPARAM) &item);
HeapFree (GetProcessHeap(), 0, (void*)item.lParam); free((void*)item.lParam);
SendMessageW(listview, LVM_DELETEITEM, selection, 0); SendMessageW(listview, LVM_DELETEITEM, selection, 0);
item.mask = LVIF_STATE; item.mask = LVIF_STATE;
item.state = LVIS_SELECTED | LVIS_FOCUSED; item.state = LVIS_SELECTED | LVIS_FOCUSED;
...@@ -510,7 +509,7 @@ void print_current_winver(void) ...@@ -510,7 +509,7 @@ void print_current_winver(void)
else else
wprintf(L"%s\n", winver); wprintf(L"%s\n", winver);
heap_free(winver); free(winver);
} }
static void on_winver_change(HWND dialog) static void on_winver_change(HWND dialog)
......
...@@ -153,8 +153,7 @@ static BOOL load_devices(IMMDeviceEnumerator *devenum, EDataFlow dataflow, ...@@ -153,8 +153,7 @@ static BOOL load_devices(IMMDeviceEnumerator *devenum, EDataFlow dataflow,
} }
if(*ndevs > 0){ if(*ndevs > 0){
*out = HeapAlloc(GetProcessHeap(), 0, *out = malloc(sizeof(struct DeviceInfo) * (*ndevs));
sizeof(struct DeviceInfo) * (*ndevs));
if(!*out){ if(!*out){
IMMDeviceCollection_Release(coll); IMMDeviceCollection_Release(coll);
return FALSE; return FALSE;
...@@ -360,10 +359,10 @@ static void initAudioDlg (HWND hDlg) ...@@ -360,10 +359,10 @@ static void initAudioDlg (HWND hDlg)
SendDlgItemMessageW(hDlg, IDC_VOICEIN_DEVICE, CB_SETCURSEL, i + 1, 0); SendDlgItemMessageW(hDlg, IDC_VOICEIN_DEVICE, CB_SETCURSEL, i + 1, 0);
} }
HeapFree(GetProcessHeap(), 0, reg_out_dev); free(reg_out_dev);
HeapFree(GetProcessHeap(), 0, reg_vout_dev); free(reg_vout_dev);
HeapFree(GetProcessHeap(), 0, reg_in_dev); free(reg_in_dev);
HeapFree(GetProcessHeap(), 0, reg_vin_dev); free(reg_vin_dev);
}else }else
swprintf(display_str, ARRAY_SIZE(display_str), format_str, disabled_str); swprintf(display_str, ARRAY_SIZE(display_str), format_str, disabled_str);
......
...@@ -102,9 +102,9 @@ BOOL add_drive(char letter, const char *targetpath, const char *device, const WC ...@@ -102,9 +102,9 @@ BOOL add_drive(char letter, const char *targetpath, const char *device, const WC
wine_dbgstr_w(label), serial, type); wine_dbgstr_w(label), serial, type);
drives[driveIndex].letter = toupper(letter); drives[driveIndex].letter = toupper(letter);
drives[driveIndex].unixpath = strdupA(targetpath); drives[driveIndex].unixpath = strdup(targetpath);
drives[driveIndex].device = device ? strdupA(device) : NULL; drives[driveIndex].device = strdup(device);
drives[driveIndex].label = label ? strdupW(label) : NULL; drives[driveIndex].label = wcsdup(label);
drives[driveIndex].serial = serial; drives[driveIndex].serial = serial;
drives[driveIndex].type = type; drives[driveIndex].type = type;
drives[driveIndex].in_use = TRUE; drives[driveIndex].in_use = TRUE;
...@@ -116,11 +116,11 @@ BOOL add_drive(char letter, const char *targetpath, const char *device, const WC ...@@ -116,11 +116,11 @@ BOOL add_drive(char letter, const char *targetpath, const char *device, const WC
/* deallocates the contents of the drive. does not free the drive itself */ /* deallocates the contents of the drive. does not free the drive itself */
void delete_drive(struct drive *d) void delete_drive(struct drive *d)
{ {
HeapFree(GetProcessHeap(), 0, d->unixpath); free(d->unixpath);
d->unixpath = NULL; d->unixpath = NULL;
HeapFree(GetProcessHeap(), 0, d->device); free(d->device);
d->device = NULL; d->device = NULL;
HeapFree(GetProcessHeap(), 0, d->label); free(d->label);
d->label = NULL; d->label = NULL;
d->serial = 0; d->serial = 0;
d->in_use = FALSE; d->in_use = FALSE;
...@@ -222,7 +222,7 @@ BOOL load_drives(void) ...@@ -222,7 +222,7 @@ BOOL load_drives(void)
struct mountmgr_unix_drive input; struct mountmgr_unix_drive input;
struct mountmgr_unix_drive *data; struct mountmgr_unix_drive *data;
if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) break; if (!(data = malloc( size ))) break;
memset( &input, 0, sizeof(input) ); memset( &input, 0, sizeof(input) );
input.letter = root[0]; input.letter = root[0];
...@@ -252,7 +252,7 @@ BOOL load_drives(void) ...@@ -252,7 +252,7 @@ BOOL load_drives(void)
if (GetLastError() == ERROR_MORE_DATA) size = data->size; if (GetLastError() == ERROR_MORE_DATA) size = data->size;
else root[0]++; /* skip this drive */ else root[0]++; /* skip this drive */
} }
HeapFree( GetProcessHeap(), 0, data ); free( data );
} }
/* reset modified flags */ /* reset modified flags */
...@@ -287,7 +287,7 @@ void apply_drive_changes(void) ...@@ -287,7 +287,7 @@ void apply_drive_changes(void)
len += strlen(drives[i].unixpath) + 1; len += strlen(drives[i].unixpath) + 1;
if (drives[i].device) len += strlen(drives[i].device) + 1; if (drives[i].device) len += strlen(drives[i].device) + 1;
} }
if (!(ioctl = HeapAlloc( GetProcessHeap(), 0, len ))) continue; if (!(ioctl = malloc( len ))) continue;
ioctl->size = len; ioctl->size = len;
ioctl->letter = 'a' + i; ioctl->letter = 'a' + i;
ioctl->device_offset = 0; ioctl->device_offset = 0;
...@@ -320,7 +320,7 @@ void apply_drive_changes(void) ...@@ -320,7 +320,7 @@ void apply_drive_changes(void)
} }
else WINE_WARN( "failed to set drive %c: to %s type %lu err %lu\n", 'a' + i, else WINE_WARN( "failed to set drive %c: to %s type %lu err %lu\n", 'a' + i,
wine_dbgstr_a(drives[i].unixpath), drives[i].type, GetLastError() ); wine_dbgstr_a(drives[i].unixpath), drives[i].type, GetLastError() );
HeapFree( GetProcessHeap(), 0, ioctl ); free( ioctl );
} }
CloseHandle( mgr ); CloseHandle( mgr );
} }
...@@ -361,7 +361,7 @@ void set_shell_folder( const WCHAR *path, const char *dest ) ...@@ -361,7 +361,7 @@ void set_shell_folder( const WCHAR *path, const char *dest )
len = sizeof(*ioctl) + nt_name.Length; len = sizeof(*ioctl) + nt_name.Length;
if (dest) len += strlen(dest) + 1; if (dest) len += strlen(dest) + 1;
if (!(ioctl = HeapAlloc( GetProcessHeap(), 0, len ))) return; if (!(ioctl = malloc( len ))) return;
ioctl->create_backup = TRUE; ioctl->create_backup = TRUE;
ioctl->folder_offset = sizeof(*ioctl); ioctl->folder_offset = sizeof(*ioctl);
ioctl->folder_size = nt_name.Length; ioctl->folder_size = nt_name.Length;
...@@ -374,6 +374,6 @@ void set_shell_folder( const WCHAR *path, const char *dest ) ...@@ -374,6 +374,6 @@ void set_shell_folder( const WCHAR *path, const char *dest )
else ioctl->symlink_offset = 0; else ioctl->symlink_offset = 0;
DeviceIoControl( mgr, IOCTL_MOUNTMGR_DEFINE_SHELL_FOLDER, ioctl, len, NULL, 0, NULL, NULL ); DeviceIoControl( mgr, IOCTL_MOUNTMGR_DEFINE_SHELL_FOLDER, ioctl, len, NULL, 0, NULL, NULL );
HeapFree( GetProcessHeap(), 0, ioctl ); free( ioctl );
RtlFreeUnicodeString( &nt_name ); RtlFreeUnicodeString( &nt_name );
} }
...@@ -54,8 +54,8 @@ static DWORD driveui_msgbox (HWND parent, UINT messageId, DWORD flags) ...@@ -54,8 +54,8 @@ static DWORD driveui_msgbox (HWND parent, UINT messageId, DWORD flags)
WCHAR* caption = load_string (IDS_WINECFG_TITLE); WCHAR* caption = load_string (IDS_WINECFG_TITLE);
WCHAR* text = load_string (messageId); WCHAR* text = load_string (messageId);
DWORD result = MessageBoxW (parent, text, caption, flags); DWORD result = MessageBoxW (parent, text, caption, flags);
HeapFree (GetProcessHeap(), 0, caption); free (caption);
HeapFree (GetProcessHeap(), 0, text); free (text);
return result; return result;
} }
...@@ -231,11 +231,11 @@ static int fill_drives_list(HWND dialog) ...@@ -231,11 +231,11 @@ static int fill_drives_list(HWND dialog)
item.lParam = (LPARAM) &drives[i]; item.lParam = (LPARAM) &drives[i];
lv_insert_item(dialog, &item); lv_insert_item(dialog, &item);
HeapFree(GetProcessHeap(), 0, item.pszText); free(item.pszText);
path = strdupU2W(drives[i].unixpath); path = strdupU2W(drives[i].unixpath);
lv_set_item_text(dialog, count, 1, path); lv_set_item_text(dialog, count, 1, path);
HeapFree(GetProcessHeap(), 0, path); free(path);
count++; count++;
} }
...@@ -433,7 +433,7 @@ static void update_controls(HWND dialog) ...@@ -433,7 +433,7 @@ static void update_controls(HWND dialog)
WINE_TRACE("set path control text to '%s'\n", current_drive->unixpath); WINE_TRACE("set path control text to '%s'\n", current_drive->unixpath);
path = strdupU2W(current_drive->unixpath); path = strdupU2W(current_drive->unixpath);
set_textW(dialog, IDC_EDIT_PATH, path); set_textW(dialog, IDC_EDIT_PATH, path);
HeapFree(GetProcessHeap(), 0, path); free(path);
/* drive type */ /* drive type */
type = current_drive->type; type = current_drive->type;
...@@ -489,7 +489,7 @@ static void on_edit_changed(HWND dialog, WORD id) ...@@ -489,7 +489,7 @@ static void on_edit_changed(HWND dialog, WORD id)
case IDC_EDIT_LABEL: case IDC_EDIT_LABEL:
{ {
WCHAR *label = get_text(dialog, id); WCHAR *label = get_text(dialog, id);
HeapFree(GetProcessHeap(), 0, current_drive->label); free(current_drive->label);
current_drive->label = label; current_drive->label = label;
current_drive->modified = TRUE; current_drive->modified = TRUE;
...@@ -509,7 +509,7 @@ static void on_edit_changed(HWND dialog, WORD id) ...@@ -509,7 +509,7 @@ static void on_edit_changed(HWND dialog, WORD id)
wpath = get_text(dialog, id); wpath = get_text(dialog, id);
if( (lenW = WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, NULL, 0, NULL, NULL)) ) if( (lenW = WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, NULL, 0, NULL, NULL)) )
{ {
path = HeapAlloc(GetProcessHeap(), 0, lenW); path = malloc(lenW);
WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, path, lenW, NULL, NULL); WideCharToMultiByte(CP_UNIXCP, 0, wpath, -1, path, lenW, NULL, NULL);
} }
else else
...@@ -518,15 +518,15 @@ static void on_edit_changed(HWND dialog, WORD id) ...@@ -518,15 +518,15 @@ static void on_edit_changed(HWND dialog, WORD id)
wpath = strdupU2W("drive_c"); wpath = strdupU2W("drive_c");
} }
HeapFree(GetProcessHeap(), 0, current_drive->unixpath); free(current_drive->unixpath);
current_drive->unixpath = path ? path : strdupA("drive_c"); current_drive->unixpath = path ? path : strdup("drive_c");
current_drive->modified = TRUE; current_drive->modified = TRUE;
WINE_TRACE("set path to %s\n", current_drive->unixpath); WINE_TRACE("set path to %s\n", current_drive->unixpath);
lv_set_item_text(dialog, lv_get_curr_select(dialog), 1, lv_set_item_text(dialog, lv_get_curr_select(dialog), 1,
wpath); wpath);
HeapFree(GetProcessHeap(), 0, wpath); free(wpath);
/* enable the apply button */ /* enable the apply button */
SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0); SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
...@@ -539,7 +539,7 @@ static void on_edit_changed(HWND dialog, WORD id) ...@@ -539,7 +539,7 @@ static void on_edit_changed(HWND dialog, WORD id)
serial = get_text(dialog, id); serial = get_text(dialog, id);
current_drive->serial = serial ? wcstoul( serial, NULL, 16 ) : 0; current_drive->serial = serial ? wcstoul( serial, NULL, 16 ) : 0;
HeapFree(GetProcessHeap(), 0, serial); free(serial);
current_drive->modified = TRUE; current_drive->modified = TRUE;
WINE_TRACE("set serial to %08lX\n", current_drive->serial); WINE_TRACE("set serial to %08lX\n", current_drive->serial);
...@@ -553,7 +553,7 @@ static void on_edit_changed(HWND dialog, WORD id) ...@@ -553,7 +553,7 @@ static void on_edit_changed(HWND dialog, WORD id)
{ {
WCHAR *device = get_text(dialog, id); WCHAR *device = get_text(dialog, id);
/* TODO: handle device if/when it makes sense to do so.... */ /* TODO: handle device if/when it makes sense to do so.... */
HeapFree(GetProcessHeap(), 0, device); free(device);
break; break;
} }
} }
......
...@@ -104,7 +104,7 @@ static enum dllmode string_to_mode(const WCHAR *in) ...@@ -104,7 +104,7 @@ static enum dllmode string_to_mode(const WCHAR *in)
enum dllmode res; enum dllmode res;
len = wcslen(in); len = wcslen(in);
out = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR)); out = malloc((len + 1) * sizeof(WCHAR));
/* remove the spaces */ /* remove the spaces */
for (i = j = 0; i <= len; ++i) { for (i = j = 0; i <= len; ++i) {
...@@ -121,7 +121,7 @@ static enum dllmode string_to_mode(const WCHAR *in) ...@@ -121,7 +121,7 @@ static enum dllmode string_to_mode(const WCHAR *in)
if (wcscmp(out, L"native") == 0) res = NATIVE; if (wcscmp(out, L"native") == 0) res = NATIVE;
if (wcscmp(out, L"") == 0) res = DISABLE; if (wcscmp(out, L"") == 0) res = DISABLE;
HeapFree(GetProcessHeap(), 0, out); free(out);
return res; return res;
} }
...@@ -244,8 +244,8 @@ static void clear_settings(HWND dialog) ...@@ -244,8 +244,8 @@ static void clear_settings(HWND dialog)
struct dll *dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, 0, 0); struct dll *dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, 0, 0);
SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_DELETESTRING, 0, 0); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_DELETESTRING, 0, 0);
HeapFree(GetProcessHeap(), 0, dll->name); free(dll->name);
HeapFree(GetProcessHeap(), 0, dll); free(dll);
} }
} }
...@@ -259,7 +259,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int ...@@ -259,7 +259,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int
WIN32_FIND_DATAW data; WIN32_FIND_DATAW data;
ULONG maxlen = wcslen(dir_path) + wcslen(pe_dir) + 10 + 2 * ARRAY_SIZE(name); ULONG maxlen = wcslen(dir_path) + wcslen(pe_dir) + 10 + 2 * ARRAY_SIZE(name);
buffer = HeapAlloc( GetProcessHeap(), 0, maxlen * sizeof(WCHAR) ); buffer = malloc( maxlen * sizeof(WCHAR) );
wcscpy( buffer, dir_path ); wcscpy( buffer, dir_path );
wcscat( buffer, L"\\*" ); wcscat( buffer, L"\\*" );
buffer[1] = '\\'; /* change \??\ to \\?\ */ buffer[1] = '\\'; /* change \??\ to \\?\ */
...@@ -267,7 +267,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int ...@@ -267,7 +267,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int
if ((handle = FindFirstFileW( buffer, &data )) == INVALID_HANDLE_VALUE) if ((handle = FindFirstFileW( buffer, &data )) == INVALID_HANDLE_VALUE)
{ {
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return; return;
} }
...@@ -310,7 +310,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int ...@@ -310,7 +310,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int
} while (FindNextFileW( handle, &data )); } while (FindNextFileW( handle, &data ));
FindClose( handle ); FindClose( handle );
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
} }
/* load the list of available libraries */ /* load the list of available libraries */
...@@ -322,11 +322,11 @@ static void load_library_list( HWND dialog ) ...@@ -322,11 +322,11 @@ static void load_library_list( HWND dialog )
if (GetEnvironmentVariableW( L"WINEBUILDDIR", path, MAX_PATH )) if (GetEnvironmentVariableW( L"WINEBUILDDIR", path, MAX_PATH ))
{ {
WCHAR *dir = HeapAlloc( GetProcessHeap(), 0, wcslen(path) * sizeof(WCHAR) + sizeof(L"\\dlls") ); WCHAR *dir = malloc( wcslen(path) * sizeof(WCHAR) + sizeof(L"\\dlls") );
wcscpy( dir, path ); wcscpy( dir, path );
wcscat( dir, L"\\dlls" ); wcscat( dir, L"\\dlls" );
load_library_list_from_dir( dialog, dir, TRUE ); load_library_list_from_dir( dialog, dir, TRUE );
HeapFree( GetProcessHeap(), 0, dir ); free( dir );
} }
for (;;) for (;;)
...@@ -374,7 +374,7 @@ static void load_library_settings(HWND dialog) ...@@ -374,7 +374,7 @@ static void load_library_settings(HWND dialog)
set_controls_from_selection(dialog); set_controls_from_selection(dialog);
disable(IDC_DLLS_EDITDLL); disable(IDC_DLLS_EDITDLL);
disable(IDC_DLLS_REMOVEDLL); disable(IDC_DLLS_REMOVEDLL);
HeapFree(GetProcessHeap(), 0, overrides); free(overrides);
return; return;
} }
...@@ -393,22 +393,22 @@ static void load_library_settings(HWND dialog) ...@@ -393,22 +393,22 @@ static void load_library_settings(HWND dialog)
label = mode_to_label(string_to_mode(value)); label = mode_to_label(string_to_mode(value));
len = wcslen(*p) + 2 + wcslen(label) + 2; len = wcslen(*p) + 2 + wcslen(label) + 2;
str = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR) ); str = malloc(len * sizeof(WCHAR));
swprintf( str, len, L"%s (%s)", *p, label ); swprintf( str, len, L"%s (%s)", *p, label );
dll = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dll)); dll = malloc(sizeof(struct dll));
dll->name = *p; dll->name = *p;
dll->mode = string_to_mode(value); dll->mode = string_to_mode(value);
index = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str); index = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str);
SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll);
HeapFree(GetProcessHeap(), 0, str); free(str);
count++; count++;
} }
HeapFree(GetProcessHeap(), 0, overrides); free(overrides);
/* restore the previous selection, if possible */ /* restore the previous selection, if possible */
if (sel >= count - 1) sel = count - 1; if (sel >= count - 1) sel = count - 1;
...@@ -594,8 +594,8 @@ static void on_remove_click(HWND dialog) ...@@ -594,8 +594,8 @@ static void on_remove_click(HWND dialog)
SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0); SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
set_reg_key(config_key, keypath(L"DllOverrides"), dll->name, NULL); set_reg_key(config_key, keypath(L"DllOverrides"), dll->name, NULL);
HeapFree(GetProcessHeap(), 0, dll->name); free(dll->name);
HeapFree(GetProcessHeap(), 0, dll); free(dll);
if (SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCOUNT, 0, 0) > 0) if (SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCOUNT, 0, 0) > 0)
SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, max(sel - 1, 0), 0); SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETCURSEL, max(sel - 1, 0), 0);
......
...@@ -94,13 +94,11 @@ static void color_or_size_dsa_add (WrappedDsa* wdsa, const WCHAR* name, ...@@ -94,13 +94,11 @@ static void color_or_size_dsa_add (WrappedDsa* wdsa, const WCHAR* name,
const WCHAR* fancyName) const WCHAR* fancyName)
{ {
ThemeColorOrSize item; ThemeColorOrSize item;
item.name = HeapAlloc (GetProcessHeap(), 0, item.name = malloc ((wcslen (name) + 1) * sizeof(WCHAR));
(lstrlenW (name) + 1) * sizeof(WCHAR));
lstrcpyW (item.name, name); lstrcpyW (item.name, name);
item.fancyName = HeapAlloc (GetProcessHeap(), 0, item.fancyName = malloc ((wcslen (fancyName) + 1) * sizeof(WCHAR));
(lstrlenW (fancyName) + 1) * sizeof(WCHAR));
lstrcpyW (item.fancyName, fancyName); lstrcpyW (item.fancyName, fancyName);
DSA_InsertItem (wdsa->dsa, wdsa->count, &item); DSA_InsertItem (wdsa->dsa, wdsa->count, &item);
...@@ -110,8 +108,8 @@ static void color_or_size_dsa_add (WrappedDsa* wdsa, const WCHAR* name, ...@@ -110,8 +108,8 @@ static void color_or_size_dsa_add (WrappedDsa* wdsa, const WCHAR* name,
static int CALLBACK dsa_destroy_callback (LPVOID p, LPVOID pData) static int CALLBACK dsa_destroy_callback (LPVOID p, LPVOID pData)
{ {
ThemeColorOrSize* item = p; ThemeColorOrSize* item = p;
HeapFree (GetProcessHeap(), 0, item->name); free (item->name);
HeapFree (GetProcessHeap(), 0, item->fancyName); free (item->fancyName);
return 1; return 1;
} }
...@@ -157,8 +155,8 @@ static int themeFilesCount = 0; ...@@ -157,8 +155,8 @@ static int themeFilesCount = 0;
static int CALLBACK theme_dsa_destroy_callback (LPVOID p, LPVOID pData) static int CALLBACK theme_dsa_destroy_callback (LPVOID p, LPVOID pData)
{ {
ThemeFile* item = p; ThemeFile* item = p;
HeapFree (GetProcessHeap(), 0, item->themeFileName); free (item->themeFileName);
HeapFree (GetProcessHeap(), 0, item->fancyName); free (item->fancyName);
free_color_or_size_dsa (&item->colors); free_color_or_size_dsa (&item->colors);
free_color_or_size_dsa (&item->sizes); free_color_or_size_dsa (&item->sizes);
return 1; return 1;
...@@ -209,12 +207,10 @@ static BOOL CALLBACK myEnumThemeProc (LPVOID lpReserved, ...@@ -209,12 +207,10 @@ static BOOL CALLBACK myEnumThemeProc (LPVOID lpReserved,
create_color_or_size_dsa (&newEntry.sizes); create_color_or_size_dsa (&newEntry.sizes);
fill_theme_string_array (pszThemeFileName, &newEntry.sizes, EnumThemeSizes); fill_theme_string_array (pszThemeFileName, &newEntry.sizes, EnumThemeSizes);
newEntry.themeFileName = HeapAlloc (GetProcessHeap(), 0, newEntry.themeFileName = malloc ((wcslen (pszThemeFileName) + 1) * sizeof(WCHAR));
(lstrlenW (pszThemeFileName) + 1) * sizeof(WCHAR));
lstrcpyW (newEntry.themeFileName, pszThemeFileName); lstrcpyW (newEntry.themeFileName, pszThemeFileName);
newEntry.fancyName = HeapAlloc (GetProcessHeap(), 0, newEntry.fancyName = malloc ((wcslen (pszThemeName) + 1) * sizeof(WCHAR));
(lstrlenW (pszThemeName) + 1) * sizeof(WCHAR));
lstrcpyW (newEntry.fancyName, pszThemeName); lstrcpyW (newEntry.fancyName, pszThemeName);
/*list_add_tail (&themeFiles, &newEntry->entry);*/ /*list_add_tail (&themeFiles, &newEntry->entry);*/
...@@ -800,7 +796,7 @@ static void update_shell_folder_listview(HWND dialog) { ...@@ -800,7 +796,7 @@ static void update_shell_folder_listview(HWND dialog) {
item.iSubItem = 1; item.iSubItem = 1;
item.pszText = strdupU2W(asfiInfo[i].szLinkTarget); item.pszText = strdupU2W(asfiInfo[i].szLinkTarget);
SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item); SendDlgItemMessageW(dialog, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
HeapFree(GetProcessHeap(), 0, item.pszText); free(item.pszText);
} }
/* Ensure that the previously selected item is selected again. */ /* Ensure that the previously selected item is selected again. */
...@@ -823,7 +819,7 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) { ...@@ -823,7 +819,7 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) {
EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 1); EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 1);
link = strdupU2W(psfiSelected->szLinkTarget); link = strdupU2W(psfiSelected->szLinkTarget);
set_textW(hDlg, IDC_EDIT_SFPATH, link); set_textW(hDlg, IDC_EDIT_SFPATH, link);
HeapFree(GetProcessHeap(), 0, link); free(link);
} else { } else {
CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED); CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0); EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0);
...@@ -849,7 +845,7 @@ static void on_shell_folder_edit_changed(HWND hDlg) { ...@@ -849,7 +845,7 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
MAKELPARAM(LVNI_SELECTED,0)); MAKELPARAM(LVNI_SELECTED,0));
if (!text || !psfiSelected || iSel < 0) { if (!text || !psfiSelected || iSel < 0) {
HeapFree(GetProcessHeap(), 0, text); free(text);
return; return;
} }
...@@ -862,7 +858,7 @@ static void on_shell_folder_edit_changed(HWND hDlg) { ...@@ -862,7 +858,7 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
item.pszText = text; item.pszText = text;
SendDlgItemMessageW(hDlg, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item); SendDlgItemMessageW(hDlg, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
HeapFree(GetProcessHeap(), 0, text); free(text);
SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0); SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
} }
...@@ -1094,7 +1090,7 @@ static void init_mime_types(HWND hDlg) ...@@ -1094,7 +1090,7 @@ static void init_mime_types(HWND hDlg)
CheckDlgButton(hDlg, IDC_ENABLE_FILE_ASSOCIATIONS, state); CheckDlgButton(hDlg, IDC_ENABLE_FILE_ASSOCIATIONS, state);
HeapFree(GetProcessHeap(), 0, buf); free(buf);
} }
static void update_mime_types(HWND hDlg) static void update_mime_types(HWND hDlg)
...@@ -1175,7 +1171,7 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -1175,7 +1171,7 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (text) if (text)
{ {
metrics[index].size = wcstol(text, NULL, 10); metrics[index].size = wcstol(text, NULL, 10);
HeapFree(GetProcessHeap(), 0, text); free(text);
} }
else else
{ {
......
...@@ -82,9 +82,9 @@ WCHAR* load_string (UINT id) ...@@ -82,9 +82,9 @@ WCHAR* load_string (UINT id)
LoadStringW(GetModuleHandleW(NULL), id, buf, ARRAY_SIZE(buf)); LoadStringW(GetModuleHandleW(NULL), id, buf, ARRAY_SIZE(buf));
len = lstrlenW (buf); len = wcslen(buf);
newStr = HeapAlloc (GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR)); newStr = malloc((len + 1) * sizeof(WCHAR));
memcpy (newStr, buf, len * sizeof (WCHAR)); memcpy(newStr, buf, len * sizeof(WCHAR));
newStr[len] = 0; newStr[len] = 0;
return newStr; return newStr;
} }
...@@ -116,7 +116,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name, ...@@ -116,7 +116,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name,
if (res == ERROR_FILE_NOT_FOUND) if (res == ERROR_FILE_NOT_FOUND)
{ {
WINE_TRACE("Section key not present - using default\n"); WINE_TRACE("Section key not present - using default\n");
return def ? strdupW(def) : NULL; return wcsdup(def);
} }
else else
{ {
...@@ -129,7 +129,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name, ...@@ -129,7 +129,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name,
if (res == ERROR_FILE_NOT_FOUND) if (res == ERROR_FILE_NOT_FOUND)
{ {
WINE_TRACE("Value not present - using default\n"); WINE_TRACE("Value not present - using default\n");
buffer = def ? strdupW(def) : NULL; buffer = wcsdup(def);
goto end; goto end;
} else if (res != ERROR_SUCCESS) } else if (res != ERROR_SUCCESS)
{ {
...@@ -137,7 +137,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name, ...@@ -137,7 +137,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name,
goto end; goto end;
} }
buffer = HeapAlloc(GetProcessHeap(), 0, len + sizeof(WCHAR)); buffer = malloc(len + sizeof(WCHAR));
RegQueryValueExW(hSubKey, name, NULL, NULL, (LPBYTE) buffer, &len); RegQueryValueExW(hSubKey, name, NULL, NULL, (LPBYTE) buffer, &len);
...@@ -228,13 +228,13 @@ static void free_setting(struct setting *setting) ...@@ -228,13 +228,13 @@ static void free_setting(struct setting *setting)
WINE_TRACE("destroying %p: %s\n", setting, WINE_TRACE("destroying %p: %s\n", setting,
wine_dbgstr_w(setting->path)); wine_dbgstr_w(setting->path));
HeapFree(GetProcessHeap(), 0, setting->path); free(setting->path);
HeapFree(GetProcessHeap(), 0, setting->name); free(setting->name);
HeapFree(GetProcessHeap(), 0, setting->value); free(setting->value);
list_remove(&setting->entry); list_remove(&setting->entry);
HeapFree(GetProcessHeap(), 0, setting); free(setting);
} }
/** /**
...@@ -243,7 +243,7 @@ static void free_setting(struct setting *setting) ...@@ -243,7 +243,7 @@ static void free_setting(struct setting *setting)
* default will be used. * default will be used.
* *
* If already in the list, the contents as given there will be * If already in the list, the contents as given there will be
* returned. You are expected to HeapFree the result. * returned. You are expected to free the result.
*/ */
WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def) WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def)
{ {
...@@ -267,7 +267,7 @@ WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR ...@@ -267,7 +267,7 @@ WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR
WINE_TRACE("found %s:%s in settings list, returning %s\n", WINE_TRACE("found %s:%s in settings list, returning %s\n",
wine_dbgstr_w(path), wine_dbgstr_w(name), wine_dbgstr_w(path), wine_dbgstr_w(name),
wine_dbgstr_w(s->value)); wine_dbgstr_w(s->value));
return s->value ? strdupW(s->value) : NULL; return wcsdup(s->value);
} }
/* no, so get from the registry */ /* no, so get from the registry */
...@@ -316,18 +316,18 @@ static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, cons ...@@ -316,18 +316,18 @@ static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, cons
if (!s->name && !name) return; if (!s->name && !name) return;
/* do we want to undelete this key? */ /* do we want to undelete this key? */
if (!s->name && name) s->name = strdupW(name); if (!s->name && name) s->name = wcsdup(name);
/* yes, we have already set it, so just replace the content and return */ /* yes, we have already set it, so just replace the content and return */
HeapFree(GetProcessHeap(), 0, s->value); free(s->value);
s->type = type; s->type = type;
switch (type) switch (type)
{ {
case REG_SZ: case REG_SZ:
s->value = value ? strdupW(value) : NULL; s->value = wcsdup(value);
break; break;
case REG_DWORD: case REG_DWORD:
s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)); s->value = malloc(sizeof(DWORD));
memcpy( s->value, value, sizeof(DWORD) ); memcpy( s->value, value, sizeof(DWORD) );
break; break;
} }
...@@ -346,18 +346,18 @@ static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, cons ...@@ -346,18 +346,18 @@ static void set_reg_key_ex(HKEY root, const WCHAR *path, const WCHAR *name, cons
} }
/* otherwise add a new setting for it */ /* otherwise add a new setting for it */
s = HeapAlloc(GetProcessHeap(), 0, sizeof(struct setting)); s = malloc(sizeof(struct setting));
s->root = root; s->root = root;
s->path = strdupW(path); s->path = wcsdup(path);
s->name = name ? strdupW(name) : NULL; s->name = wcsdup(name);
s->type = type; s->type = type;
switch (type) switch (type)
{ {
case REG_SZ: case REG_SZ:
s->value = value ? strdupW(value) : NULL; s->value = wcsdup(value);
break; break;
case REG_DWORD: case REG_DWORD:
s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)); s->value = malloc(sizeof(DWORD));
memcpy( s->value, value, sizeof(DWORD) ); memcpy( s->value, value, sizeof(DWORD) );
break; break;
} }
...@@ -379,7 +379,7 @@ void set_reg_key_dword(HKEY root, const WCHAR *path, const WCHAR *name, DWORD va ...@@ -379,7 +379,7 @@ void set_reg_key_dword(HKEY root, const WCHAR *path, const WCHAR *name, DWORD va
* enumerates the value names at the given path, taking into account * enumerates the value names at the given path, taking into account
* the changes in the settings list. * the changes in the settings list.
* *
* you are expected to HeapFree each element of the array, which is null * you are expected to free each element of the array, which is null
* terminated, as well as the array itself. * terminated, as well as the array itself.
*/ */
WCHAR **enumerate_values(HKEY root, const WCHAR *path) WCHAR **enumerate_values(HKEY root, const WCHAR *path)
...@@ -426,10 +426,9 @@ WCHAR **enumerate_values(HKEY root, const WCHAR *path) ...@@ -426,10 +426,9 @@ WCHAR **enumerate_values(HKEY root, const WCHAR *path)
} }
/* grow the array if necessary, add buffer to it, iterate */ /* grow the array if necessary, add buffer to it, iterate */
if (values) values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1)); values = realloc(values, sizeof(WCHAR*) * (valueslen + 1));
else values = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR*));
values[valueslen++] = strdupW(name); values[valueslen++] = wcsdup(name);
WINE_TRACE("valueslen is now %ld\n", valueslen); WINE_TRACE("valueslen is now %ld\n", valueslen);
i++; i++;
} }
...@@ -466,16 +465,15 @@ WCHAR **enumerate_values(HKEY root, const WCHAR *path) ...@@ -466,16 +465,15 @@ WCHAR **enumerate_values(HKEY root, const WCHAR *path)
WINE_TRACE("%s in list but not registry\n", wine_dbgstr_w(setting->name)); WINE_TRACE("%s in list but not registry\n", wine_dbgstr_w(setting->name));
/* otherwise it's been set by the user but isn't in the registry */ /* otherwise it's been set by the user but isn't in the registry */
if (values) values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1)); values = realloc(values, sizeof(WCHAR*) * (valueslen + 1));
else values = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR*));
values[valueslen++] = strdupW(setting->name); values[valueslen++] = wcsdup(setting->name);
} }
WINE_TRACE("adding null terminator\n"); WINE_TRACE("adding null terminator\n");
if (values) if (values)
{ {
values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1)); values = realloc(values, sizeof(WCHAR*) * (valueslen + 1));
values[valueslen] = NULL; values[valueslen] = NULL;
} }
...@@ -492,7 +490,7 @@ BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name) ...@@ -492,7 +490,7 @@ BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name)
{ {
WCHAR *val = get_reg_key(root, path, name, NULL); WCHAR *val = get_reg_key(root, path, name, NULL);
HeapFree(GetProcessHeap(), 0, val); free(val);
return val != NULL; return val != NULL;
} }
...@@ -568,12 +566,12 @@ WCHAR *keypath(const WCHAR *section) ...@@ -568,12 +566,12 @@ WCHAR *keypath(const WCHAR *section)
{ {
static WCHAR *result = NULL; static WCHAR *result = NULL;
HeapFree(GetProcessHeap(), 0, result); free(result);
if (current_app) if (current_app)
{ {
DWORD len = sizeof(L"AppDefaults\\") + (lstrlenW(current_app) + lstrlenW(section) + 1) * sizeof(WCHAR); DWORD len = sizeof(L"AppDefaults\\") + (lstrlenW(current_app) + lstrlenW(section) + 1) * sizeof(WCHAR);
result = HeapAlloc(GetProcessHeap(), 0, len ); result = malloc(len);
lstrcpyW( result, L"AppDefaults\\" ); lstrcpyW( result, L"AppDefaults\\" );
lstrcatW( result, current_app ); lstrcatW( result, current_app );
if (section[0]) if (section[0])
...@@ -585,7 +583,7 @@ WCHAR *keypath(const WCHAR *section) ...@@ -585,7 +583,7 @@ WCHAR *keypath(const WCHAR *section)
} }
else else
{ {
result = strdupW(section); result = wcsdup(section);
} }
return result; return result;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define WINE_CFG_H #define WINE_CFG_H
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
...@@ -47,7 +48,7 @@ extern WCHAR* current_app; /* NULL means editing global settings */ ...@@ -47,7 +48,7 @@ extern WCHAR* current_app; /* NULL means editing global settings */
The root HKEY has to be non-ambiguous. So only the registry roots (HKCU, HKLM, ...) or The root HKEY has to be non-ambiguous. So only the registry roots (HKCU, HKLM, ...) or
the global config_key are allowed here. the global config_key are allowed here.
You are expected to HeapFree the result of get_reg_key. The parameters to set_reg_key will You are expected to free the result of get_reg_key. The parameters to set_reg_key will
be copied, so free them too when necessary. be copied, so free them too when necessary.
*/ */
...@@ -59,7 +60,7 @@ BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name); ...@@ -59,7 +60,7 @@ BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name);
void apply(void); void apply(void);
WCHAR **enumerate_values(HKEY root, const WCHAR *path); WCHAR **enumerate_values(HKEY root, const WCHAR *path);
/* Load a string from the resources. Allocated with HeapAlloc (GetProcessHeap()) */ /* Load a string from the resources. Allocated with malloc */
WCHAR* load_string (UINT id); WCHAR* load_string (UINT id);
/* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if /* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
...@@ -123,19 +124,6 @@ extern struct drive drives[26]; /* one for each drive letter */ ...@@ -123,19 +124,6 @@ extern struct drive drives[26]; /* one for each drive letter */
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1); #define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */ void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
/* returns a string in the win32 heap */
static inline char *strdupA(const char *s)
{
char *r = HeapAlloc(GetProcessHeap(), 0, strlen(s)+1);
return strcpy(r, s);
}
static inline WCHAR *strdupW(const WCHAR *s)
{
WCHAR *r = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(s)+1)*sizeof(WCHAR));
return lstrcpyW(r, s);
}
/* create a unicode string from a string in Unix locale */ /* create a unicode string from a string in Unix locale */
static inline WCHAR *strdupU2W(const char *unix_str) static inline WCHAR *strdupU2W(const char *unix_str)
{ {
...@@ -143,7 +131,7 @@ static inline WCHAR *strdupU2W(const char *unix_str) ...@@ -143,7 +131,7 @@ static inline WCHAR *strdupU2W(const char *unix_str)
int lenW; int lenW;
lenW = MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, NULL, 0); lenW = MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, NULL, 0);
unicode_str = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR)); unicode_str = malloc(lenW * sizeof(WCHAR));
if (unicode_str) if (unicode_str)
MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, unicode_str, lenW); MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, unicode_str, lenW);
return unicode_str; return unicode_str;
...@@ -153,10 +141,10 @@ static inline WCHAR *get_text(HWND dialog, WORD id) ...@@ -153,10 +141,10 @@ static inline WCHAR *get_text(HWND dialog, WORD id)
{ {
HWND item = GetDlgItem(dialog, id); HWND item = GetDlgItem(dialog, id);
int len = GetWindowTextLengthW(item) + 1; int len = GetWindowTextLengthW(item) + 1;
WCHAR *result = len ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL; WCHAR *result = len ? malloc(len * sizeof(WCHAR)) : NULL;
if (!result) return NULL; if (!result) return NULL;
if(GetWindowTextW(item, result, len) == 0) { if(GetWindowTextW(item, result, len) == 0) {
HeapFree (GetProcessHeap(), 0, result); free(result);
return NULL; return NULL;
} }
return result; return result;
......
...@@ -55,7 +55,7 @@ static void convert_x11_desktop_key(void) ...@@ -55,7 +55,7 @@ static void convert_x11_desktop_key(void)
set_reg_key(config_key, L"Explorer\\Desktops", L"Default", buf); set_reg_key(config_key, L"Explorer\\Desktops", L"Default", buf);
set_reg_key(config_key, L"Explorer", L"Desktop", L"Default"); set_reg_key(config_key, L"Explorer", L"Desktop", L"Default");
set_reg_key(config_key, L"X11 Driver", L"Desktop", NULL); set_reg_key(config_key, L"X11 Driver", L"Desktop", NULL);
HeapFree(GetProcessHeap(), 0, buf); free(buf);
} }
static void update_gui_for_desktop_mode(HWND dialog) static void update_gui_for_desktop_mode(HWND dialog)
...@@ -77,7 +77,7 @@ static void update_gui_for_desktop_mode(HWND dialog) ...@@ -77,7 +77,7 @@ static void update_gui_for_desktop_mode(HWND dialog)
SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, L"800"); SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, L"800");
SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, L"600"); SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, L"600");
} }
HeapFree(GetProcessHeap(), 0, buf); free(buf);
/* do we have desktop mode enabled? */ /* do we have desktop mode enabled? */
if (reg_key_exists(config_key, keypath(L"Explorer"), L"Desktop")) if (reg_key_exists(config_key, keypath(L"Explorer"), L"Desktop"))
...@@ -115,7 +115,7 @@ static BOOL can_enable_desktop(void) ...@@ -115,7 +115,7 @@ static BOOL can_enable_desktop(void)
{ {
if(wcscmp(value, L"winemac.drv")) if(wcscmp(value, L"winemac.drv"))
ret = TRUE; ret = TRUE;
HeapFree(GetProcessHeap(), 0, value); free(value);
} }
return ret; return ret;
} }
...@@ -144,21 +144,21 @@ static void init_dialog(HWND dialog) ...@@ -144,21 +144,21 @@ static void init_dialog(HWND dialog)
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_CHECKED); CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_CHECKED);
else else
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_UNCHECKED); CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf); free(buf);
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"Y"); buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Managed", L"Y");
if (IS_OPTION_TRUE(*buf)) if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_CHECKED); CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_CHECKED);
else else
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_UNCHECKED); CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf); free(buf);
buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"Y"); buf = get_reg_key(config_key, keypath(L"X11 Driver"), L"Decorated", L"Y");
if (IS_OPTION_TRUE(*buf)) if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_CHECKED); CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_CHECKED);
else else
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_UNCHECKED); CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf); free(buf);
updating_ui = FALSE; updating_ui = FALSE;
} }
...@@ -184,8 +184,8 @@ static void set_from_desktop_edits(HWND dialog) ...@@ -184,8 +184,8 @@ static void set_from_desktop_edits(HWND dialog)
set_reg_key(config_key, L"Explorer\\Desktops", desktop_name, buffer); set_reg_key(config_key, L"Explorer\\Desktops", desktop_name, buffer);
set_reg_key(config_key, keypath(L"Explorer"), L"Desktop", desktop_name); set_reg_key(config_key, keypath(L"Explorer"), L"Desktop", desktop_name);
HeapFree(GetProcessHeap(), 0, width); free(width);
HeapFree(GetProcessHeap(), 0, height); free(height);
} }
static void on_enable_desktop_clicked(HWND dialog) { static void on_enable_desktop_clicked(HWND dialog) {
...@@ -234,7 +234,7 @@ static INT read_logpixels_reg(void) ...@@ -234,7 +234,7 @@ static INT read_logpixels_reg(void)
WCHAR *buf = get_reg_key(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", NULL); WCHAR *buf = get_reg_key(HKEY_CURRENT_USER, L"Control Panel\\Desktop", L"LogPixels", NULL);
if (!buf) buf = get_reg_key(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", NULL); if (!buf) buf = get_reg_key(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", NULL);
dwLogPixels = buf ? *buf : DEFDPI; dwLogPixels = buf ? *buf : DEFDPI;
HeapFree(GetProcessHeap(), 0, buf); free(buf);
return dwLogPixels; return dwLogPixels;
} }
......
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