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)
L"RegisteredOrganization", org ? org : L"");
apply();
HeapFree(GetProcessHeap(), 0, owner);
HeapFree(GetProcessHeap(), 0, org);
free(owner);
free(org);
break;
case NM_CLICK:
......@@ -90,8 +90,8 @@ AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
SendMessageW(GetParent(hDlg), PSM_UNCHANGED, 0, 0);
HeapFree(GetProcessHeap(), 0, owner);
HeapFree(GetProcessHeap(), 0, org);
free(owner);
free(org);
/* prepare the panel */
hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
......
......@@ -28,7 +28,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "wine/heap.h"
#include "winecfg.h"
#include "resource.h"
......@@ -139,7 +138,7 @@ static void update_comboboxes(HWND dialog)
if (!winver || !winver[0])
{
HeapFree(GetProcessHeap(), 0, winver);
free(winver);
if (current_app) /* no explicit setting */
{
......@@ -147,8 +146,8 @@ static void update_comboboxes(HWND dialog)
SendDlgItemMessageW(dialog, IDC_WINVER, CB_SETCURSEL, 0, 0);
return;
}
if (ver != -1) winver = strdupW( win_versions[ver].szVersion );
else winver = strdupW(DEFAULT_WIN_VERSION);
if (ver != -1) winver = wcsdup(win_versions[ver].szVersion);
else winver = wcsdup(DEFAULT_WIN_VERSION);
}
WINE_TRACE("winver is %s\n", debugstr_w(winver));
......@@ -164,7 +163,7 @@ static void update_comboboxes(HWND dialog)
}
}
HeapFree(GetProcessHeap(), 0, winver);
free(winver);
}
static void
......@@ -229,7 +228,7 @@ static void init_appsheet(HWND dialog)
size = ARRAY_SIZE(appname);
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++;
size = ARRAY_SIZE(appname);
......@@ -355,7 +354,7 @@ static void on_add_app_click(HWND dialog)
if (list_contains_file(listview, filetitle))
return;
new_app = strdupW(filetitle);
new_app = wcsdup(filetitle);
WINE_TRACE("adding %s\n", wine_dbgstr_w (new_app));
......@@ -387,7 +386,7 @@ static void on_remove_app_click(HWND dialog)
set_reg_key(config_key, keypath(L""), NULL, NULL); /* delete the section */
SendMessageW(listview, LVM_GETITEMW, 0, (LPARAM) &item);
HeapFree (GetProcessHeap(), 0, (void*)item.lParam);
free((void*)item.lParam);
SendMessageW(listview, LVM_DELETEITEM, selection, 0);
item.mask = LVIF_STATE;
item.state = LVIS_SELECTED | LVIS_FOCUSED;
......@@ -510,7 +509,7 @@ void print_current_winver(void)
else
wprintf(L"%s\n", winver);
heap_free(winver);
free(winver);
}
static void on_winver_change(HWND dialog)
......
......@@ -153,8 +153,7 @@ static BOOL load_devices(IMMDeviceEnumerator *devenum, EDataFlow dataflow,
}
if(*ndevs > 0){
*out = HeapAlloc(GetProcessHeap(), 0,
sizeof(struct DeviceInfo) * (*ndevs));
*out = malloc(sizeof(struct DeviceInfo) * (*ndevs));
if(!*out){
IMMDeviceCollection_Release(coll);
return FALSE;
......@@ -360,10 +359,10 @@ static void initAudioDlg (HWND hDlg)
SendDlgItemMessageW(hDlg, IDC_VOICEIN_DEVICE, CB_SETCURSEL, i + 1, 0);
}
HeapFree(GetProcessHeap(), 0, reg_out_dev);
HeapFree(GetProcessHeap(), 0, reg_vout_dev);
HeapFree(GetProcessHeap(), 0, reg_in_dev);
HeapFree(GetProcessHeap(), 0, reg_vin_dev);
free(reg_out_dev);
free(reg_vout_dev);
free(reg_in_dev);
free(reg_vin_dev);
}else
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
wine_dbgstr_w(label), serial, type);
drives[driveIndex].letter = toupper(letter);
drives[driveIndex].unixpath = strdupA(targetpath);
drives[driveIndex].device = device ? strdupA(device) : NULL;
drives[driveIndex].label = label ? strdupW(label) : NULL;
drives[driveIndex].unixpath = strdup(targetpath);
drives[driveIndex].device = strdup(device);
drives[driveIndex].label = wcsdup(label);
drives[driveIndex].serial = serial;
drives[driveIndex].type = type;
drives[driveIndex].in_use = TRUE;
......@@ -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 */
void delete_drive(struct drive *d)
{
HeapFree(GetProcessHeap(), 0, d->unixpath);
free(d->unixpath);
d->unixpath = NULL;
HeapFree(GetProcessHeap(), 0, d->device);
free(d->device);
d->device = NULL;
HeapFree(GetProcessHeap(), 0, d->label);
free(d->label);
d->label = NULL;
d->serial = 0;
d->in_use = FALSE;
......@@ -222,7 +222,7 @@ BOOL load_drives(void)
struct mountmgr_unix_drive input;
struct mountmgr_unix_drive *data;
if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) break;
if (!(data = malloc( size ))) break;
memset( &input, 0, sizeof(input) );
input.letter = root[0];
......@@ -252,7 +252,7 @@ BOOL load_drives(void)
if (GetLastError() == ERROR_MORE_DATA) size = data->size;
else root[0]++; /* skip this drive */
}
HeapFree( GetProcessHeap(), 0, data );
free( data );
}
/* reset modified flags */
......@@ -287,7 +287,7 @@ void apply_drive_changes(void)
len += strlen(drives[i].unixpath) + 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->letter = 'a' + i;
ioctl->device_offset = 0;
......@@ -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,
wine_dbgstr_a(drives[i].unixpath), drives[i].type, GetLastError() );
HeapFree( GetProcessHeap(), 0, ioctl );
free( ioctl );
}
CloseHandle( mgr );
}
......@@ -361,7 +361,7 @@ void set_shell_folder( const WCHAR *path, const char *dest )
len = sizeof(*ioctl) + nt_name.Length;
if (dest) len += strlen(dest) + 1;
if (!(ioctl = HeapAlloc( GetProcessHeap(), 0, len ))) return;
if (!(ioctl = malloc( len ))) return;
ioctl->create_backup = TRUE;
ioctl->folder_offset = sizeof(*ioctl);
ioctl->folder_size = nt_name.Length;
......@@ -374,6 +374,6 @@ void set_shell_folder( const WCHAR *path, const char *dest )
else ioctl->symlink_offset = 0;
DeviceIoControl( mgr, IOCTL_MOUNTMGR_DEFINE_SHELL_FOLDER, ioctl, len, NULL, 0, NULL, NULL );
HeapFree( GetProcessHeap(), 0, ioctl );
free( ioctl );
RtlFreeUnicodeString( &nt_name );
}
......@@ -54,8 +54,8 @@ static DWORD driveui_msgbox (HWND parent, UINT messageId, DWORD flags)
WCHAR* caption = load_string (IDS_WINECFG_TITLE);
WCHAR* text = load_string (messageId);
DWORD result = MessageBoxW (parent, text, caption, flags);
HeapFree (GetProcessHeap(), 0, caption);
HeapFree (GetProcessHeap(), 0, text);
free (caption);
free (text);
return result;
}
......@@ -231,11 +231,11 @@ static int fill_drives_list(HWND dialog)
item.lParam = (LPARAM) &drives[i];
lv_insert_item(dialog, &item);
HeapFree(GetProcessHeap(), 0, item.pszText);
free(item.pszText);
path = strdupU2W(drives[i].unixpath);
lv_set_item_text(dialog, count, 1, path);
HeapFree(GetProcessHeap(), 0, path);
free(path);
count++;
}
......@@ -433,7 +433,7 @@ static void update_controls(HWND dialog)
WINE_TRACE("set path control text to '%s'\n", current_drive->unixpath);
path = strdupU2W(current_drive->unixpath);
set_textW(dialog, IDC_EDIT_PATH, path);
HeapFree(GetProcessHeap(), 0, path);
free(path);
/* drive type */
type = current_drive->type;
......@@ -489,7 +489,7 @@ static void on_edit_changed(HWND dialog, WORD id)
case IDC_EDIT_LABEL:
{
WCHAR *label = get_text(dialog, id);
HeapFree(GetProcessHeap(), 0, current_drive->label);
free(current_drive->label);
current_drive->label = label;
current_drive->modified = TRUE;
......@@ -509,7 +509,7 @@ static void on_edit_changed(HWND dialog, WORD id)
wpath = get_text(dialog, id);
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);
}
else
......@@ -518,15 +518,15 @@ static void on_edit_changed(HWND dialog, WORD id)
wpath = strdupU2W("drive_c");
}
HeapFree(GetProcessHeap(), 0, current_drive->unixpath);
current_drive->unixpath = path ? path : strdupA("drive_c");
free(current_drive->unixpath);
current_drive->unixpath = path ? path : strdup("drive_c");
current_drive->modified = TRUE;
WINE_TRACE("set path to %s\n", current_drive->unixpath);
lv_set_item_text(dialog, lv_get_curr_select(dialog), 1,
wpath);
HeapFree(GetProcessHeap(), 0, wpath);
free(wpath);
/* enable the apply button */
SendMessageW(GetParent(dialog), PSM_CHANGED, (WPARAM) dialog, 0);
......@@ -539,7 +539,7 @@ static void on_edit_changed(HWND dialog, WORD id)
serial = get_text(dialog, id);
current_drive->serial = serial ? wcstoul( serial, NULL, 16 ) : 0;
HeapFree(GetProcessHeap(), 0, serial);
free(serial);
current_drive->modified = TRUE;
WINE_TRACE("set serial to %08lX\n", current_drive->serial);
......@@ -553,7 +553,7 @@ static void on_edit_changed(HWND dialog, WORD id)
{
WCHAR *device = get_text(dialog, id);
/* TODO: handle device if/when it makes sense to do so.... */
HeapFree(GetProcessHeap(), 0, device);
free(device);
break;
}
}
......
......@@ -104,7 +104,7 @@ static enum dllmode string_to_mode(const WCHAR *in)
enum dllmode res;
len = wcslen(in);
out = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
out = malloc((len + 1) * sizeof(WCHAR));
/* remove the spaces */
for (i = j = 0; i <= len; ++i) {
......@@ -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"") == 0) res = DISABLE;
HeapFree(GetProcessHeap(), 0, out);
free(out);
return res;
}
......@@ -244,8 +244,8 @@ static void clear_settings(HWND dialog)
struct dll *dll = (struct dll *) SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETITEMDATA, 0, 0);
SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_DELETESTRING, 0, 0);
HeapFree(GetProcessHeap(), 0, dll->name);
HeapFree(GetProcessHeap(), 0, dll);
free(dll->name);
free(dll);
}
}
......@@ -259,7 +259,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int
WIN32_FIND_DATAW data;
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 );
wcscat( buffer, L"\\*" );
buffer[1] = '\\'; /* change \??\ to \\?\ */
......@@ -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)
{
HeapFree( GetProcessHeap(), 0, buffer );
free( buffer );
return;
}
......@@ -310,7 +310,7 @@ static void load_library_list_from_dir( HWND dialog, const WCHAR *dir_path, int
} while (FindNextFileW( handle, &data ));
FindClose( handle );
HeapFree( GetProcessHeap(), 0, buffer );
free( buffer );
}
/* load the list of available libraries */
......@@ -322,11 +322,11 @@ static void load_library_list( HWND dialog )
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 );
wcscat( dir, L"\\dlls" );
load_library_list_from_dir( dialog, dir, TRUE );
HeapFree( GetProcessHeap(), 0, dir );
free( dir );
}
for (;;)
......@@ -374,7 +374,7 @@ static void load_library_settings(HWND dialog)
set_controls_from_selection(dialog);
disable(IDC_DLLS_EDITDLL);
disable(IDC_DLLS_REMOVEDLL);
HeapFree(GetProcessHeap(), 0, overrides);
free(overrides);
return;
}
......@@ -393,22 +393,22 @@ static void load_library_settings(HWND dialog)
label = mode_to_label(string_to_mode(value));
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 );
dll = HeapAlloc(GetProcessHeap(), 0, sizeof(struct dll));
dll = malloc(sizeof(struct dll));
dll->name = *p;
dll->mode = string_to_mode(value);
index = SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_ADDSTRING, (WPARAM) -1, (LPARAM) str);
SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_SETITEMDATA, index, (LPARAM) dll);
HeapFree(GetProcessHeap(), 0, str);
free(str);
count++;
}
HeapFree(GetProcessHeap(), 0, overrides);
free(overrides);
/* restore the previous selection, if possible */
if (sel >= count - 1) sel = count - 1;
......@@ -594,8 +594,8 @@ static void on_remove_click(HWND dialog)
SendMessageW(GetParent(dialog), PSM_CHANGED, 0, 0);
set_reg_key(config_key, keypath(L"DllOverrides"), dll->name, NULL);
HeapFree(GetProcessHeap(), 0, dll->name);
HeapFree(GetProcessHeap(), 0, dll);
free(dll->name);
free(dll);
if (SendDlgItemMessageW(dialog, IDC_DLLS_LIST, LB_GETCOUNT, 0, 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,
const WCHAR* fancyName)
{
ThemeColorOrSize item;
item.name = HeapAlloc (GetProcessHeap(), 0,
(lstrlenW (name) + 1) * sizeof(WCHAR));
item.name = malloc ((wcslen (name) + 1) * sizeof(WCHAR));
lstrcpyW (item.name, name);
item.fancyName = HeapAlloc (GetProcessHeap(), 0,
(lstrlenW (fancyName) + 1) * sizeof(WCHAR));
item.fancyName = malloc ((wcslen (fancyName) + 1) * sizeof(WCHAR));
lstrcpyW (item.fancyName, fancyName);
DSA_InsertItem (wdsa->dsa, wdsa->count, &item);
......@@ -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)
{
ThemeColorOrSize* item = p;
HeapFree (GetProcessHeap(), 0, item->name);
HeapFree (GetProcessHeap(), 0, item->fancyName);
free (item->name);
free (item->fancyName);
return 1;
}
......@@ -157,8 +155,8 @@ static int themeFilesCount = 0;
static int CALLBACK theme_dsa_destroy_callback (LPVOID p, LPVOID pData)
{
ThemeFile* item = p;
HeapFree (GetProcessHeap(), 0, item->themeFileName);
HeapFree (GetProcessHeap(), 0, item->fancyName);
free (item->themeFileName);
free (item->fancyName);
free_color_or_size_dsa (&item->colors);
free_color_or_size_dsa (&item->sizes);
return 1;
......@@ -209,12 +207,10 @@ static BOOL CALLBACK myEnumThemeProc (LPVOID lpReserved,
create_color_or_size_dsa (&newEntry.sizes);
fill_theme_string_array (pszThemeFileName, &newEntry.sizes, EnumThemeSizes);
newEntry.themeFileName = HeapAlloc (GetProcessHeap(), 0,
(lstrlenW (pszThemeFileName) + 1) * sizeof(WCHAR));
newEntry.themeFileName = malloc ((wcslen (pszThemeFileName) + 1) * sizeof(WCHAR));
lstrcpyW (newEntry.themeFileName, pszThemeFileName);
newEntry.fancyName = HeapAlloc (GetProcessHeap(), 0,
(lstrlenW (pszThemeName) + 1) * sizeof(WCHAR));
newEntry.fancyName = malloc ((wcslen (pszThemeName) + 1) * sizeof(WCHAR));
lstrcpyW (newEntry.fancyName, pszThemeName);
/*list_add_tail (&themeFiles, &newEntry->entry);*/
......@@ -800,7 +796,7 @@ static void update_shell_folder_listview(HWND dialog) {
item.iSubItem = 1;
item.pszText = strdupU2W(asfiInfo[i].szLinkTarget);
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. */
......@@ -823,7 +819,7 @@ static void on_shell_folder_selection_changed(HWND hDlg, LPNMLISTVIEW lpnm) {
EnableWindow(GetDlgItem(hDlg, IDC_BROWSE_SFPATH), 1);
link = strdupU2W(psfiSelected->szLinkTarget);
set_textW(hDlg, IDC_EDIT_SFPATH, link);
HeapFree(GetProcessHeap(), 0, link);
free(link);
} else {
CheckDlgButton(hDlg, IDC_LINK_SFPATH, BST_UNCHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_EDIT_SFPATH), 0);
......@@ -849,7 +845,7 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
MAKELPARAM(LVNI_SELECTED,0));
if (!text || !psfiSelected || iSel < 0) {
HeapFree(GetProcessHeap(), 0, text);
free(text);
return;
}
......@@ -862,7 +858,7 @@ static void on_shell_folder_edit_changed(HWND hDlg) {
item.pszText = text;
SendDlgItemMessageW(hDlg, IDC_LIST_SFPATHS, LVM_SETITEMW, 0, (LPARAM)&item);
HeapFree(GetProcessHeap(), 0, text);
free(text);
SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
}
......@@ -1094,7 +1090,7 @@ static void init_mime_types(HWND hDlg)
CheckDlgButton(hDlg, IDC_ENABLE_FILE_ASSOCIATIONS, state);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
static void update_mime_types(HWND hDlg)
......@@ -1175,7 +1171,7 @@ ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (text)
{
metrics[index].size = wcstol(text, NULL, 10);
HeapFree(GetProcessHeap(), 0, text);
free(text);
}
else
{
......
......@@ -82,9 +82,9 @@ WCHAR* load_string (UINT id)
LoadStringW(GetModuleHandleW(NULL), id, buf, ARRAY_SIZE(buf));
len = lstrlenW (buf);
newStr = HeapAlloc (GetProcessHeap(), 0, (len + 1) * sizeof (WCHAR));
memcpy (newStr, buf, len * sizeof (WCHAR));
len = wcslen(buf);
newStr = malloc((len + 1) * sizeof(WCHAR));
memcpy(newStr, buf, len * sizeof(WCHAR));
newStr[len] = 0;
return newStr;
}
......@@ -116,7 +116,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name,
if (res == ERROR_FILE_NOT_FOUND)
{
WINE_TRACE("Section key not present - using default\n");
return def ? strdupW(def) : NULL;
return wcsdup(def);
}
else
{
......@@ -129,7 +129,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name,
if (res == ERROR_FILE_NOT_FOUND)
{
WINE_TRACE("Value not present - using default\n");
buffer = def ? strdupW(def) : NULL;
buffer = wcsdup(def);
goto end;
} else if (res != ERROR_SUCCESS)
{
......@@ -137,7 +137,7 @@ static WCHAR *get_config_key (HKEY root, const WCHAR *subkey, const WCHAR *name,
goto end;
}
buffer = HeapAlloc(GetProcessHeap(), 0, len + sizeof(WCHAR));
buffer = malloc(len + sizeof(WCHAR));
RegQueryValueExW(hSubKey, name, NULL, NULL, (LPBYTE) buffer, &len);
......@@ -228,13 +228,13 @@ static void free_setting(struct setting *setting)
WINE_TRACE("destroying %p: %s\n", setting,
wine_dbgstr_w(setting->path));
HeapFree(GetProcessHeap(), 0, setting->path);
HeapFree(GetProcessHeap(), 0, setting->name);
HeapFree(GetProcessHeap(), 0, setting->value);
free(setting->path);
free(setting->name);
free(setting->value);
list_remove(&setting->entry);
HeapFree(GetProcessHeap(), 0, setting);
free(setting);
}
/**
......@@ -243,7 +243,7 @@ static void free_setting(struct setting *setting)
* default will be used.
*
* 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)
{
......@@ -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_dbgstr_w(path), wine_dbgstr_w(name),
wine_dbgstr_w(s->value));
return s->value ? strdupW(s->value) : NULL;
return wcsdup(s->value);
}
/* 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
if (!s->name && !name) return;
/* 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 */
HeapFree(GetProcessHeap(), 0, s->value);
free(s->value);
s->type = type;
switch (type)
{
case REG_SZ:
s->value = value ? strdupW(value) : NULL;
s->value = wcsdup(value);
break;
case REG_DWORD:
s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
s->value = malloc(sizeof(DWORD));
memcpy( s->value, value, sizeof(DWORD) );
break;
}
......@@ -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 */
s = HeapAlloc(GetProcessHeap(), 0, sizeof(struct setting));
s = malloc(sizeof(struct setting));
s->root = root;
s->path = strdupW(path);
s->name = name ? strdupW(name) : NULL;
s->path = wcsdup(path);
s->name = wcsdup(name);
s->type = type;
switch (type)
{
case REG_SZ:
s->value = value ? strdupW(value) : NULL;
s->value = wcsdup(value);
break;
case REG_DWORD:
s->value = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
s->value = malloc(sizeof(DWORD));
memcpy( s->value, value, sizeof(DWORD) );
break;
}
......@@ -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
* 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.
*/
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 */
if (values) values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1));
else values = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR*));
values = realloc(values, sizeof(WCHAR*) * (valueslen + 1));
values[valueslen++] = strdupW(name);
values[valueslen++] = wcsdup(name);
WINE_TRACE("valueslen is now %ld\n", valueslen);
i++;
}
......@@ -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));
/* 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));
else values = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR*));
values = realloc(values, sizeof(WCHAR*) * (valueslen + 1));
values[valueslen++] = strdupW(setting->name);
values[valueslen++] = wcsdup(setting->name);
}
WINE_TRACE("adding null terminator\n");
if (values)
{
values = HeapReAlloc(GetProcessHeap(), 0, values, sizeof(WCHAR*) * (valueslen + 1));
values = realloc(values, sizeof(WCHAR*) * (valueslen + 1));
values[valueslen] = NULL;
}
......@@ -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);
HeapFree(GetProcessHeap(), 0, val);
free(val);
return val != NULL;
}
......@@ -568,12 +566,12 @@ WCHAR *keypath(const WCHAR *section)
{
static WCHAR *result = NULL;
HeapFree(GetProcessHeap(), 0, result);
free(result);
if (current_app)
{
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\\" );
lstrcatW( result, current_app );
if (section[0])
......@@ -585,7 +583,7 @@ WCHAR *keypath(const WCHAR *section)
}
else
{
result = strdupW(section);
result = wcsdup(section);
}
return result;
......
......@@ -25,6 +25,7 @@
#define WINE_CFG_H
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
......@@ -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 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.
*/
......@@ -59,7 +60,7 @@ BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name);
void apply(void);
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);
/* 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 */
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
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 */
static inline WCHAR *strdupU2W(const char *unix_str)
{
......@@ -143,7 +131,7 @@ static inline WCHAR *strdupU2W(const char *unix_str)
int lenW;
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)
MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, unicode_str, lenW);
return unicode_str;
......@@ -153,10 +141,10 @@ static inline WCHAR *get_text(HWND dialog, WORD id)
{
HWND item = GetDlgItem(dialog, id);
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(GetWindowTextW(item, result, len) == 0) {
HeapFree (GetProcessHeap(), 0, result);
free(result);
return NULL;
}
return result;
......
......@@ -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", L"Desktop", L"Default");
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)
......@@ -77,7 +77,7 @@ static void update_gui_for_desktop_mode(HWND dialog)
SetDlgItemTextW(dialog, IDC_DESKTOP_WIDTH, L"800");
SetDlgItemTextW(dialog, IDC_DESKTOP_HEIGHT, L"600");
}
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
/* do we have desktop mode enabled? */
if (reg_key_exists(config_key, keypath(L"Explorer"), L"Desktop"))
......@@ -115,7 +115,7 @@ static BOOL can_enable_desktop(void)
{
if(wcscmp(value, L"winemac.drv"))
ret = TRUE;
HeapFree(GetProcessHeap(), 0, value);
free(value);
}
return ret;
}
......@@ -144,21 +144,21 @@ static void init_dialog(HWND dialog)
CheckDlgButton(dialog, IDC_FULLSCREEN_GRAB, BST_CHECKED);
else
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");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_CHECKED);
else
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");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_CHECKED);
else
CheckDlgButton(dialog, IDC_ENABLE_DECORATED, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
updating_ui = FALSE;
}
......@@ -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, keypath(L"Explorer"), L"Desktop", desktop_name);
HeapFree(GetProcessHeap(), 0, width);
HeapFree(GetProcessHeap(), 0, height);
free(width);
free(height);
}
static void on_enable_desktop_clicked(HWND dialog) {
......@@ -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);
if (!buf) buf = get_reg_key(HKEY_CURRENT_CONFIG, L"Software\\Fonts", L"LogPixels", NULL);
dwLogPixels = buf ? *buf : DEFDPI;
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
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