Commit a6063f83 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit: Replace heap_x*() functions with malloc(), realloc() and free().

parent de0794a1
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "main.h" #include "main.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(regedit); WINE_DEFAULT_DEBUG_CHANNEL(regedit);
...@@ -99,7 +98,7 @@ static LPWSTR CombinePaths(LPCWSTR pPaths[], int nPaths) { ...@@ -99,7 +98,7 @@ static LPWSTR CombinePaths(LPCWSTR pPaths[], int nPaths) {
len += lstrlenW(pPaths[i])+1; len += lstrlenW(pPaths[i])+1;
} }
} }
combined = heap_xalloc(len * sizeof(WCHAR)); combined = malloc(len * sizeof(WCHAR));
*combined = '\0'; *combined = '\0';
for (i=0, pos=0; i<nPaths; i++) { for (i=0, pos=0; i<nPaths; i++) {
if (pPaths[i] && *pPaths[i]) { if (pPaths[i] && *pPaths[i]) {
...@@ -122,7 +121,7 @@ static LPWSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) { ...@@ -122,7 +121,7 @@ static LPWSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
HKEY hRootKey = NULL; HKEY hRootKey = NULL;
if (!hItem) if (!hItem)
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0); hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
heap_free(GetItemPath(hwndTV, hItem, &hRootKey)); free(GetItemPath(hwndTV, hItem, &hRootKey));
if (!bFull && !hRootKey) if (!bFull && !hRootKey)
return NULL; return NULL;
if (hRootKey) if (hRootKey)
...@@ -143,8 +142,8 @@ LPWSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) { ...@@ -143,8 +142,8 @@ LPWSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
parts[0] = GetPathRoot(hwndTV, hItem, bFull); parts[0] = GetPathRoot(hwndTV, hItem, bFull);
parts[1] = GetItemPath(hwndTV, hItem, &hRootKey); parts[1] = GetItemPath(hwndTV, hItem, &hRootKey);
ret = CombinePaths((LPCWSTR *)parts, 2); ret = CombinePaths((LPCWSTR *)parts, 2);
heap_free(parts[0]); free(parts[0]);
heap_free(parts[1]); free(parts[1]);
return ret; return ret;
} }
...@@ -165,7 +164,7 @@ static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BO ...@@ -165,7 +164,7 @@ static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BO
keyPath = GetItemPath(hwndTV, hItem, &hRootKey); keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
RefreshListView(hwndLV, hRootKey, keyPath, NULL); RefreshListView(hwndLV, hRootKey, keyPath, NULL);
heap_free(keyPath); free(keyPath);
} }
UpdateStatusBar(); UpdateStatusBar();
} }
...@@ -272,7 +271,7 @@ static void set_last_key(HWND hwndTV) ...@@ -272,7 +271,7 @@ static void set_last_key(HWND hwndTV)
value = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE); value = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE);
RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)value, (lstrlenW(value) + 1) * sizeof(WCHAR)); RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)value, (lstrlenW(value) + 1) * sizeof(WCHAR));
if (selection != root) if (selection != root)
heap_free(value); free(value);
RegCloseKey(hkey); RegCloseKey(hkey);
} }
} }
...@@ -304,7 +303,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ...@@ -304,7 +303,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
WCHAR *path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); WCHAR *path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText); BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText);
heap_free(path); free(path);
if (res) if (res)
{ {
...@@ -317,7 +316,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ...@@ -317,7 +316,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey); path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
update_listview_path(path); update_listview_path(path);
heap_free(path); free(path);
UpdateStatusBar(); UpdateStatusBar();
} }
...@@ -391,9 +390,9 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ...@@ -391,9 +390,9 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
LINE_INFO *info = (LINE_INFO *)nmlv->lParam; LINE_INFO *info = (LINE_INFO *)nmlv->lParam;
heap_free(info->name); free(info->name);
heap_free(info->val); free(info->val);
heap_free(info); free(info);
break; break;
} }
case LVN_ENDLABELEDITW: case LVN_ENDLABELEDITW:
...@@ -412,7 +411,7 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ...@@ -412,7 +411,7 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
dispInfo->item.iItem, (LPARAM)&dispInfo->item); dispInfo->item.iItem, (LPARAM)&dispInfo->item);
} }
heap_free(oldName); free(oldName);
return 0; return 0;
} }
case LVN_GETDISPINFOW: case LVN_GETDISPINFOW:
...@@ -440,7 +439,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa ...@@ -440,7 +439,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{ {
switch (message) { switch (message) {
case WM_CREATE: case WM_CREATE:
g_pChildWnd = heap_xalloc(sizeof(ChildWnd)); g_pChildWnd = malloc(sizeof(ChildWnd));
if (!g_pChildWnd) return 0; if (!g_pChildWnd) return 0;
LoadStringW(hInst, IDS_REGISTRY_ROOT_NAME, g_pChildWnd->szPath, MAX_PATH); LoadStringW(hInst, IDS_REGISTRY_ROOT_NAME, g_pChildWnd->szPath, MAX_PATH);
g_pChildWnd->nSplitPos = 250; g_pChildWnd->nSplitPos = 250;
...@@ -472,7 +471,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa ...@@ -472,7 +471,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
goto def; goto def;
case WM_DESTROY: case WM_DESTROY:
set_last_key(g_pChildWnd->hTreeWnd); set_last_key(g_pChildWnd->hTreeWnd);
heap_free(g_pChildWnd); free(g_pChildWnd);
g_pChildWnd = NULL; g_pChildWnd = NULL;
PostQuitMessage(0); PostQuitMessage(0);
break; break;
......
...@@ -24,11 +24,9 @@ ...@@ -24,11 +24,9 @@
#include <commctrl.h> #include <commctrl.h>
#include <commdlg.h> #include <commdlg.h>
#include <cderr.h> #include <cderr.h>
#include <stdlib.h>
#include <shellapi.h> #include <shellapi.h>
#include <shlwapi.h> #include <shlwapi.h>
#include "wine/heap.h"
#include "main.h" #include "main.h"
static const WCHAR* editValueName; static const WCHAR* editValueName;
...@@ -120,7 +118,7 @@ static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L ...@@ -120,7 +118,7 @@ static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case IDOK: case IDOK:
if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) { if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
len = GetWindowTextLengthW(hwndValue); len = GetWindowTextLengthW(hwndValue);
stringValueData = heap_xrealloc(stringValueData, (len + 1) * sizeof(WCHAR)); stringValueData = realloc(stringValueData, (len + 1) * sizeof(WCHAR));
if (!GetWindowTextW(hwndValue, stringValueData, len + 1)) if (!GetWindowTextW(hwndValue, stringValueData, len + 1))
*stringValueData = 0; *stringValueData = 0;
} }
...@@ -156,11 +154,11 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara ...@@ -156,11 +154,11 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara
case IDOK: case IDOK:
params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER); params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
size = SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_GETDATA, 0, 0); size = SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_GETDATA, 0, 0);
data = heap_xalloc(size); data = malloc(size);
SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_GETDATA, (WPARAM)size, (LPARAM)data); SendDlgItemMessageW(hwndDlg, IDC_VALUE_DATA, HEM_GETDATA, (WPARAM)size, (LPARAM)data);
lRet = RegSetValueExW(params->hkey, params->value_name, 0, params->type, data, size); lRet = RegSetValueExW(params->hkey, params->value_name, 0, params->type, data, size);
heap_free(data); free(data);
if (lRet == ERROR_SUCCESS) if (lRet == ERROR_SUCCESS)
EndDialog(hwndDlg, 1); EndDialog(hwndDlg, 1);
...@@ -189,7 +187,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType, ...@@ -189,7 +187,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
if (lRet == ERROR_FILE_NOT_FOUND && !valueName) { /* no default value here, make it up */ if (lRet == ERROR_FILE_NOT_FOUND && !valueName) { /* no default value here, make it up */
if (len) *len = 1; if (len) *len = 1;
if (lpType) *lpType = REG_SZ; if (lpType) *lpType = REG_SZ;
buffer = heap_xalloc(sizeof(WCHAR)); buffer = malloc(sizeof(WCHAR));
*buffer = '\0'; *buffer = '\0';
return buffer; return buffer;
} }
...@@ -197,7 +195,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType, ...@@ -197,7 +195,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
goto done; goto done;
} }
buffer = heap_xalloc(valueDataLen + sizeof(WCHAR)); buffer = malloc(valueDataLen + sizeof(WCHAR));
lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)buffer, &valueDataLen); lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)buffer, &valueDataLen);
if (lRet) { if (lRet) {
error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName); error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
...@@ -209,7 +207,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType, ...@@ -209,7 +207,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
return buffer; return buffer;
done: done:
heap_free(buffer); free(buffer);
return NULL; return NULL;
} }
...@@ -277,7 +275,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -277,7 +275,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
} }
} else if ( type == REG_DWORD ) { } else if ( type == REG_DWORD ) {
DWORD value = *((DWORD*)stringValueData); DWORD value = *((DWORD*)stringValueData);
stringValueData = heap_xrealloc(stringValueData, 64); stringValueData = realloc(stringValueData, 64);
wsprintfW(stringValueData, L"%x", value); wsprintfW(stringValueData, L"%x", value);
if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc) == IDOK) if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc) == IDOK)
{ {
...@@ -291,7 +289,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -291,7 +289,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
} }
} else if ( type == REG_QWORD ) { } else if ( type == REG_QWORD ) {
UINT64 value = *((UINT64 *)stringValueData); UINT64 value = *((UINT64 *)stringValueData);
stringValueData = heap_xrealloc(stringValueData, 64); stringValueData = realloc(stringValueData, 64);
swprintf(stringValueData, 64, L"%I64x", value); swprintf(stringValueData, 64, L"%I64x", value);
if (DialogBoxParamW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc, type) == IDOK) if (DialogBoxParamW(0, MAKEINTRESOURCEW(IDD_EDIT_DWORD), hwnd, modify_dlgproc, type) == IDOK)
{ {
...@@ -310,7 +308,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -310,7 +308,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
for (i = 0, count = 0; i < len / sizeof(WCHAR); i++) for (i = 0, count = 0; i < len / sizeof(WCHAR); i++)
if ( !stringValueData[i] && stringValueData[i + 1] ) if ( !stringValueData[i] && stringValueData[i + 1] )
count++; count++;
tmpValueData = heap_xalloc(len + (count * sizeof(WCHAR))); tmpValueData = malloc(len + (count * sizeof(WCHAR)));
for ( i = 0, j = 0; i < len / sizeof(WCHAR); i++) for ( i = 0, j = 0; i < len / sizeof(WCHAR); i++)
{ {
...@@ -323,14 +321,14 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -323,14 +321,14 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
tmpValueData[j++] = stringValueData[i]; tmpValueData[j++] = stringValueData[i];
} }
heap_free(stringValueData); free(stringValueData);
stringValueData = tmpValueData; stringValueData = tmpValueData;
tmpValueData = NULL; tmpValueData = NULL;
if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_MULTI_STRING), hwnd, modify_dlgproc) == IDOK) if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_MULTI_STRING), hwnd, modify_dlgproc) == IDOK)
{ {
len = lstrlenW( stringValueData ); len = lstrlenW( stringValueData );
tmpValueData = heap_xalloc((len + 2) * sizeof(WCHAR)); tmpValueData = malloc((len + 2) * sizeof(WCHAR));
for (i = 0, j = 0; i < len; i++) for (i = 0, j = 0; i < len; i++)
{ {
...@@ -346,7 +344,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -346,7 +344,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
tmpValueData[j++] = 0; tmpValueData[j++] = 0;
tmpValueData[j++] = 0; tmpValueData[j++] = 0;
heap_free(stringValueData); free(stringValueData);
stringValueData = tmpValueData; stringValueData = tmpValueData;
lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, j * sizeof(WCHAR)); lRet = RegSetValueExW(hKey, valueName, 0, type, (LPBYTE)stringValueData, j * sizeof(WCHAR));
...@@ -372,13 +370,13 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) ...@@ -372,13 +370,13 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
{ {
int index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, int index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0)); MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
heap_free(stringValueData); free(stringValueData);
stringValueData = read_value(hwnd, hKey, valueName, &type, &len); stringValueData = read_value(hwnd, hKey, valueName, &type, &len);
format_value_data(g_pChildWnd->hListWnd, index, type, stringValueData, len); format_value_data(g_pChildWnd->hListWnd, index, type, stringValueData, len);
} }
done: done:
heap_free(stringValueData); free(stringValueData);
stringValueData = NULL; stringValueData = NULL;
RegCloseKey(hKey); RegCloseKey(hKey);
return result; return result;
...@@ -538,7 +536,7 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC ...@@ -538,7 +536,7 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
result = TRUE; result = TRUE;
done: done:
heap_free(value); free(value);
RegCloseKey(hKey); RegCloseKey(hKey);
return result; return result;
} }
...@@ -562,7 +560,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName) ...@@ -562,7 +560,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
} else { } else {
LPWSTR srcSubKey_copy; LPWSTR srcSubKey_copy;
parentPath = heap_xalloc((lstrlenW(keyPath) + 1) * sizeof(WCHAR)); parentPath = malloc((lstrlenW(keyPath) + 1) * sizeof(WCHAR));
lstrcpyW(parentPath, keyPath); lstrcpyW(parentPath, keyPath);
srcSubKey_copy = wcsrchr(parentPath, '\\'); srcSubKey_copy = wcsrchr(parentPath, '\\');
*srcSubKey_copy = 0; *srcSubKey_copy = 0;
...@@ -607,7 +605,7 @@ done: ...@@ -607,7 +605,7 @@ done:
RegCloseKey(destKey); RegCloseKey(destKey);
if (parentKey) { if (parentKey) {
RegCloseKey(parentKey); RegCloseKey(parentKey);
heap_free(parentPath); free(parentPath);
} }
return result; return result;
} }
...@@ -24,12 +24,10 @@ ...@@ -24,12 +24,10 @@
#include <commctrl.h> #include <commctrl.h>
#include <commdlg.h> #include <commdlg.h>
#include <cderr.h> #include <cderr.h>
#include <stdlib.h>
#include <shellapi.h> #include <shellapi.h>
#include "main.h" #include "main.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(regedit); WINE_DEFAULT_DEBUG_CHANNEL(regedit);
...@@ -188,7 +186,7 @@ static void UpdateMenuItems(HMENU hMenu) { ...@@ -188,7 +186,7 @@ static void UpdateMenuItems(HMENU hMenu) {
EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE, EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE,
(GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); (GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
heap_free(keyName); free(keyName);
} }
static void add_remove_modify_menu_items(HMENU hMenu) static void add_remove_modify_menu_items(HMENU hMenu)
...@@ -227,7 +225,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList) ...@@ -227,7 +225,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList)
if (!num_values) goto exit; if (!num_values) goto exit;
max_value_len++; max_value_len++;
value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); value_name = malloc(max_value_len * sizeof(WCHAR));
if (hMenu) AppendMenuW(hMenu, MF_SEPARATOR, 0, 0); if (hMenu) AppendMenuW(hMenu, MF_SEPARATOR, 0, 0);
...@@ -244,7 +242,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList) ...@@ -244,7 +242,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList)
} }
} }
heap_free(value_name); free(value_name);
exit: exit:
RegCloseKey(hkey); RegCloseKey(hkey);
return i; return i;
...@@ -303,7 +301,7 @@ void UpdateStatusBar(void) ...@@ -303,7 +301,7 @@ void UpdateStatusBar(void)
{ {
LPWSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, TRUE); LPWSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, TRUE);
SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath); SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
heap_free(fullPath); free(fullPath);
} }
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild) static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
...@@ -361,12 +359,12 @@ static void ExportRegistryFile_StoreSelection(HWND hdlg, OPENFILENAMEW *pOpenFil ...@@ -361,12 +359,12 @@ static void ExportRegistryFile_StoreSelection(HWND hdlg, OPENFILENAMEW *pOpenFil
if (IsDlgButtonChecked(hdlg, IDC_EXPORT_SELECTED)) if (IsDlgButtonChecked(hdlg, IDC_EXPORT_SELECTED))
{ {
INT len = SendDlgItemMessageW(hdlg, IDC_EXPORT_PATH, WM_GETTEXTLENGTH, 0, 0); INT len = SendDlgItemMessageW(hdlg, IDC_EXPORT_PATH, WM_GETTEXTLENGTH, 0, 0);
pOpenFileName->lCustData = (LPARAM)heap_xalloc((len + 1) * sizeof(WCHAR)); pOpenFileName->lCustData = (LPARAM)malloc((len + 1) * sizeof(WCHAR));
SendDlgItemMessageW(hdlg, IDC_EXPORT_PATH, WM_GETTEXT, len+1, pOpenFileName->lCustData); SendDlgItemMessageW(hdlg, IDC_EXPORT_PATH, WM_GETTEXT, len+1, pOpenFileName->lCustData);
} }
else else
{ {
pOpenFileName->lCustData = (LPARAM)heap_xalloc(sizeof(WCHAR)); pOpenFileName->lCustData = (LPARAM)malloc(sizeof(WCHAR));
*(WCHAR *)pOpenFileName->lCustData = 0; *(WCHAR *)pOpenFileName->lCustData = 0;
} }
} }
...@@ -395,7 +393,7 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W ...@@ -395,7 +393,7 @@ static UINT_PTR CALLBACK ExportRegistryFile_OFNHookProc(HWND hdlg, UINT uiMsg, W
SendDlgItemMessageW(hdlg, IDC_EXPORT_PATH, WM_SETTEXT, 0, (LPARAM)path); SendDlgItemMessageW(hdlg, IDC_EXPORT_PATH, WM_SETTEXT, 0, (LPARAM)path);
if (path && path[0]) if (path && path[0])
export_branch = TRUE; export_branch = TRUE;
heap_free(path); free(path);
CheckRadioButton(hdlg, IDC_EXPORT_ALL, IDC_EXPORT_SELECTED, export_branch ? IDC_EXPORT_SELECTED : IDC_EXPORT_ALL); CheckRadioButton(hdlg, IDC_EXPORT_ALL, IDC_EXPORT_SELECTED, export_branch ? IDC_EXPORT_SELECTED : IDC_EXPORT_ALL);
break; break;
} }
...@@ -481,7 +479,7 @@ static BOOL ImportRegistryFile(HWND hWnd) ...@@ -481,7 +479,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
key_path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &root_key); key_path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &root_key);
RefreshListView(g_pChildWnd->hListWnd, root_key, key_path, NULL); RefreshListView(g_pChildWnd->hListWnd, root_key, key_path, NULL);
heap_free(key_path); free(key_path);
return TRUE; return TRUE;
} }
...@@ -724,13 +722,13 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w ...@@ -724,13 +722,13 @@ static INT_PTR CALLBACK removefavorite_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
int pos = SendMessageW(hwndList, LB_GETCURSEL, 0, 0); int pos = SendMessageW(hwndList, LB_GETCURSEL, 0, 0);
int len = SendMessageW(hwndList, LB_GETTEXTLEN, pos, 0); int len = SendMessageW(hwndList, LB_GETTEXTLEN, pos, 0);
if (len>0) { if (len>0) {
WCHAR *lpName = heap_xalloc((len + 1) * sizeof(WCHAR)); WCHAR *lpName = malloc((len + 1) * sizeof(WCHAR));
SendMessageW(hwndList, LB_GETTEXT, pos, (LPARAM)lpName); SendMessageW(hwndList, LB_GETTEXT, pos, (LPARAM)lpName);
if (len>127) if (len>127)
lpName[127] = '\0'; lpName[127] = '\0';
lstrcpyW(favoriteName, lpName); lstrcpyW(favoriteName, lpName);
EndDialog(hwndDlg, IDOK); EndDialog(hwndDlg, IDOK);
heap_free(lpName); free(lpName);
} }
return TRUE; return TRUE;
} }
...@@ -795,7 +793,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -795,7 +793,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} else if (DeleteKey(hWnd, hKeyRoot, keyPath)) { } else if (DeleteKey(hWnd, hKeyRoot, keyPath)) {
DeleteNode(g_pChildWnd->hTreeWnd, 0); DeleteNode(g_pChildWnd->hTreeWnd, 0);
} }
heap_free(keyPath); free(keyPath);
} else if (hWndDelete == g_pChildWnd->hListWnd) { } else if (hWndDelete == g_pChildWnd->hListWnd) {
unsigned int num_selected, index, focus_idx; unsigned int num_selected, index, focus_idx;
WCHAR *keyPath; WCHAR *keyPath;
...@@ -822,10 +820,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -822,10 +820,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR *valueName = GetItemText(g_pChildWnd->hListWnd, index); WCHAR *valueName = GetItemText(g_pChildWnd->hListWnd, index);
if (!DeleteValue(hWnd, hKeyRoot, keyPath, valueName)) if (!DeleteValue(hWnd, hKeyRoot, keyPath, valueName))
{ {
heap_free(valueName); free(valueName);
break; break;
} }
heap_free(valueName); free(valueName);
SendMessageW(g_pChildWnd->hListWnd, LVM_DELETEITEM, index, 0L); SendMessageW(g_pChildWnd->hListWnd, LVM_DELETEITEM, index, 0L);
/* the default value item is always visible, so add it back in */ /* the default value item is always visible, so add it back in */
if (!index) if (!index)
...@@ -840,7 +838,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -840,7 +838,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} }
index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_SELECTED, 0)); index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_SELECTED, 0));
} }
heap_free(keyPath); free(keyPath);
} else if (IsChild(g_pChildWnd->hTreeWnd, hWndDelete) || } else if (IsChild(g_pChildWnd->hTreeWnd, hWndDelete) ||
IsChild(g_pChildWnd->hListWnd, hWndDelete)) { IsChild(g_pChildWnd->hListWnd, hWndDelete)) {
SendMessageW(hWndDelete, WM_KEYDOWN, VK_DELETE, 0); SendMessageW(hWndDelete, WM_KEYDOWN, VK_DELETE, 0);
...@@ -853,8 +851,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -853,8 +851,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR *valueName = GetValueName(g_pChildWnd->hListWnd); WCHAR *valueName = GetValueName(g_pChildWnd->hListWnd);
WCHAR *keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); WCHAR *keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
ModifyValue(hWnd, hKeyRoot, keyPath, valueName); ModifyValue(hWnd, hKeyRoot, keyPath, valueName);
heap_free(keyPath); free(keyPath);
heap_free(valueName); free(valueName);
break; break;
} }
case ID_EDIT_FIND: case ID_EDIT_FIND:
...@@ -901,7 +899,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -901,7 +899,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LPWSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE); LPWSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
if (fullPath) { if (fullPath) {
CopyKeyName(hWnd, fullPath); CopyKeyName(hWnd, fullPath);
heap_free(fullPath); free(fullPath);
} }
break; break;
} }
...@@ -913,7 +911,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -913,7 +911,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKeyW)) if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKeyW))
StartKeyRename(g_pChildWnd->hTreeWnd); StartKeyRename(g_pChildWnd->hTreeWnd);
} }
heap_free(keyPath); free(keyPath);
} }
break; break;
case ID_EDIT_NEW_STRINGVALUE: case ID_EDIT_NEW_STRINGVALUE:
...@@ -940,7 +938,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -940,7 +938,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR newKey[MAX_NEW_KEY_LEN]; WCHAR newKey[MAX_NEW_KEY_LEN];
if (CreateValue(hWnd, hKeyRoot, keyPath, valueType, newKey)) if (CreateValue(hWnd, hKeyRoot, keyPath, valueType, newKey))
StartValueRename(g_pChildWnd->hListWnd); StartValueRename(g_pChildWnd->hListWnd);
heap_free(keyPath); free(keyPath);
} }
break; break;
case ID_EDIT_RENAME: case ID_EDIT_RENAME:
...@@ -954,7 +952,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -954,7 +952,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} else if (GetFocus() == g_pChildWnd->hListWnd) { } else if (GetFocus() == g_pChildWnd->hListWnd) {
StartValueRename(g_pChildWnd->hListWnd); StartValueRename(g_pChildWnd->hListWnd);
} }
heap_free(keyPath); free(keyPath);
break; break;
} }
case ID_TREE_EXPAND_COLLAPSE: case ID_TREE_EXPAND_COLLAPSE:
...@@ -987,7 +985,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -987,7 +985,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
RegCloseKey(hKey); RegCloseKey(hKey);
} }
} }
heap_free(lpKeyPath); free(lpKeyPath);
} }
break; break;
} }
...@@ -1008,7 +1006,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -1008,7 +1006,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR* keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); WCHAR* keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
RefreshTreeView(g_pChildWnd->hTreeWnd); RefreshTreeView(g_pChildWnd->hTreeWnd);
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL); RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL);
heap_free(keyPath); free(keyPath);
} }
break; break;
/*case ID_OPTIONS_TOOLBAR:*/ /*case ID_OPTIONS_TOOLBAR:*/
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "winnls.h" #include "winnls.h"
#include "commctrl.h" #include "commctrl.h"
#include "wine/heap.h"
#include "main.h" #include "main.h"
/* spaces dividing hex and ASCII */ /* spaces dividing hex and ASCII */
...@@ -71,7 +70,7 @@ static inline BYTE hexchar_to_byte(WCHAR ch) ...@@ -71,7 +70,7 @@ static inline BYTE hexchar_to_byte(WCHAR ch)
static LPWSTR HexEdit_GetLineText(int offset, BYTE *pData, LONG cbData, LONG pad) static LPWSTR HexEdit_GetLineText(int offset, BYTE *pData, LONG cbData, LONG pad)
{ {
WCHAR *lpszLine = heap_xalloc((6 + cbData * 3 + pad * 3 + DIV_SPACES + cbData + 1) * sizeof(WCHAR)); WCHAR *lpszLine = malloc((6 + cbData * 3 + pad * 3 + DIV_SPACES + cbData + 1) * sizeof(WCHAR));
LONG i; LONG i;
wsprintfW(lpszLine, L"%04X ", offset); wsprintfW(lpszLine, L"%04X ", offset);
...@@ -133,7 +132,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr) ...@@ -133,7 +132,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
TextOutW(hdc, nXStart, nYStart, lpszLine, lstrlenW(lpszLine)); TextOutW(hdc, nXStart, nYStart, lpszLine, lstrlenW(lpszLine));
nYStart += infoPtr->nHeight; nYStart += infoPtr->nHeight;
heap_free(lpszLine); free(lpszLine);
} }
SelectObject(hdc, hOldFont); SelectObject(hdc, hOldFont);
...@@ -172,7 +171,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr) ...@@ -172,7 +171,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
if (!nLineLen) size.cx = 0; if (!nLineLen) size.cx = 0;
heap_free(lpszLine); free(lpszLine);
SetCaretPos( SetCaretPos(
GetSystemMetrics(SM_CXBORDER) + size.cx, GetSystemMetrics(SM_CXBORDER) + size.cx,
...@@ -224,10 +223,10 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos) ...@@ -224,10 +223,10 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
static LRESULT static LRESULT
HexEdit_SetData(HEXEDIT_INFO *infoPtr, INT cbData, const BYTE *pData) HexEdit_SetData(HEXEDIT_INFO *infoPtr, INT cbData, const BYTE *pData)
{ {
heap_free(infoPtr->pData); free(infoPtr->pData);
infoPtr->cbData = 0; infoPtr->cbData = 0;
infoPtr->pData = heap_xalloc(cbData); infoPtr->pData = malloc(cbData);
memcpy(infoPtr->pData, pData, cbData); memcpy(infoPtr->pData, pData, cbData);
infoPtr->cbData = cbData; infoPtr->cbData = cbData;
...@@ -286,7 +285,7 @@ HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch) ...@@ -286,7 +285,7 @@ HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch)
{ {
/* make room for another byte */ /* make room for another byte */
infoPtr->cbData++; infoPtr->cbData++;
infoPtr->pData = heap_xrealloc(infoPtr->pData, infoPtr->cbData + 1); infoPtr->pData = realloc(infoPtr->pData, infoPtr->cbData + 1);
/* move everything after caret up one byte */ /* move everything after caret up one byte */
memmove(infoPtr->pData + nCaretBytePos + 1, memmove(infoPtr->pData + nCaretBytePos + 1,
...@@ -328,9 +327,9 @@ static inline LRESULT ...@@ -328,9 +327,9 @@ static inline LRESULT
HexEdit_Destroy (HEXEDIT_INFO *infoPtr) HexEdit_Destroy (HEXEDIT_INFO *infoPtr)
{ {
HWND hwnd = infoPtr->hwndSelf; HWND hwnd = infoPtr->hwndSelf;
heap_free(infoPtr->pData); free(infoPtr->pData);
/* free info data */ /* free info data */
heap_free(infoPtr); free(infoPtr);
SetWindowLongPtrW(hwnd, 0, 0); SetWindowLongPtrW(hwnd, 0, 0);
return 0; return 0;
} }
...@@ -430,7 +429,7 @@ static inline LRESULT HexEdit_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs) ...@@ -430,7 +429,7 @@ static inline LRESULT HexEdit_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs)
lpcs->dwExStyle | WS_EX_CLIENTEDGE); lpcs->dwExStyle | WS_EX_CLIENTEDGE);
/* allocate memory for info structure */ /* allocate memory for info structure */
infoPtr = heap_xalloc(sizeof(HEXEDIT_INFO)); infoPtr = malloc(sizeof(HEXEDIT_INFO));
memset(infoPtr, 0, sizeof(HEXEDIT_INFO)); memset(infoPtr, 0, sizeof(HEXEDIT_INFO));
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr); SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
...@@ -479,15 +478,15 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw) ...@@ -479,15 +478,15 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
for (i = 0; ; i++) for (i = 0; ; i++)
{ {
BYTE *pData = heap_xalloc(i); BYTE *pData = malloc(i);
WCHAR *lpszLine; WCHAR *lpszLine;
SIZE size; SIZE size;
memset(pData, 0, i); memset(pData, 0, i);
lpszLine = HexEdit_GetLineText(0, pData, i, 0); lpszLine = HexEdit_GetLineText(0, pData, i, 0);
GetTextExtentPoint32W(hdc, lpszLine, lstrlenW(lpszLine), &size); GetTextExtentPoint32W(hdc, lpszLine, lstrlenW(lpszLine), &size);
heap_free(lpszLine); free(lpszLine);
heap_free(pData); free(pData);
if (size.cx > (rcClient.right - rcClient.left)) if (size.cx > (rcClient.right - rcClient.left))
{ {
infoPtr->nBytesPerLine = i - 1; infoPtr->nBytesPerLine = i - 1;
......
...@@ -22,10 +22,8 @@ ...@@ -22,10 +22,8 @@
#include <windows.h> #include <windows.h>
#include <winternl.h> #include <winternl.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h>
#include "main.h" #include "main.h"
#include "wine/heap.h"
static INT Image_String; static INT Image_String;
static INT Image_Binary; static INT Image_Binary;
...@@ -50,14 +48,14 @@ LPWSTR GetItemText(HWND hwndLV, UINT item) ...@@ -50,14 +48,14 @@ LPWSTR GetItemText(HWND hwndLV, UINT item)
unsigned int maxLen = 128; unsigned int maxLen = 128;
if (item == 0) return NULL; /* first item is ALWAYS a default */ if (item == 0) return NULL; /* first item is ALWAYS a default */
curStr = heap_xalloc(maxLen * sizeof(WCHAR)); curStr = malloc(maxLen * sizeof(WCHAR));
do { do {
ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen); ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen);
if (lstrlenW(curStr) < maxLen - 1) return curStr; if (lstrlenW(curStr) < maxLen - 1) return curStr;
maxLen *= 2; maxLen *= 2;
curStr = heap_xrealloc(curStr, maxLen * sizeof(WCHAR)); curStr = realloc(curStr, maxLen * sizeof(WCHAR));
} while (TRUE); } while (TRUE);
heap_free(curStr); free(curStr);
return NULL; return NULL;
} }
...@@ -73,9 +71,9 @@ WCHAR *GetValueName(HWND hwndLV) ...@@ -73,9 +71,9 @@ WCHAR *GetValueName(HWND hwndLV)
BOOL update_listview_path(const WCHAR *path) BOOL update_listview_path(const WCHAR *path)
{ {
heap_free(g_currentPath); free(g_currentPath);
g_currentPath = heap_xalloc((lstrlenW(path) + 1) * sizeof(WCHAR)); g_currentPath = malloc((lstrlenW(path) + 1) * sizeof(WCHAR));
lstrcpyW(g_currentPath, path); lstrcpyW(g_currentPath, path);
return TRUE; return TRUE;
...@@ -136,12 +134,12 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz ...@@ -136,12 +134,12 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz
{ {
unsigned int i; unsigned int i;
BYTE *pData = data; BYTE *pData = data;
WCHAR *strBinary = heap_xalloc(size * sizeof(WCHAR) * 3 + sizeof(WCHAR)); WCHAR *strBinary = malloc(size * sizeof(WCHAR) * 3 + sizeof(WCHAR));
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
wsprintfW( strBinary + i*3, L"%02X ", pData[i] ); wsprintfW( strBinary + i*3, L"%02X ", pData[i] );
strBinary[size * 3] = 0; strBinary[size * 3] = 0;
ListView_SetItemTextW(hwndLV, index, 2, strBinary); ListView_SetItemTextW(hwndLV, index, 2, strBinary);
heap_free(strBinary); free(strBinary);
break; break;
} }
} }
...@@ -153,20 +151,20 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR ...@@ -153,20 +151,20 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR
LVITEMW item = { 0 }; LVITEMW item = { 0 };
int index; int index;
linfo = heap_xalloc(sizeof(LINE_INFO)); linfo = malloc(sizeof(LINE_INFO));
linfo->dwValType = dwValType; linfo->dwValType = dwValType;
linfo->val_len = dwCount; linfo->val_len = dwCount;
if (Name) if (Name)
{ {
linfo->name = heap_xalloc((lstrlenW(Name) + 1) * sizeof(WCHAR)); linfo->name = malloc((lstrlenW(Name) + 1) * sizeof(WCHAR));
lstrcpyW(linfo->name, Name); lstrcpyW(linfo->name, Name);
} }
else linfo->name = NULL; else linfo->name = NULL;
if (ValBuf && dwCount) if (ValBuf && dwCount)
{ {
linfo->val = heap_xalloc(dwCount); linfo->val = malloc(dwCount);
memcpy(linfo->val, ValBuf, dwCount); memcpy(linfo->val, ValBuf, dwCount);
} }
else linfo->val = NULL; else linfo->val = NULL;
...@@ -411,8 +409,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli ...@@ -411,8 +409,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
max_val_name_len++; max_val_name_len++;
max_val_size++; max_val_size++;
valName = heap_xalloc(max_val_name_len * sizeof(WCHAR)); valName = malloc(max_val_name_len * sizeof(WCHAR));
valBuf = heap_xalloc(max_val_size); valBuf = malloc(max_val_size);
valSize = max_val_size; valSize = max_val_size;
if (RegQueryValueExW(hKey, NULL, NULL, &valType, valBuf, &valSize) == ERROR_FILE_NOT_FOUND) { if (RegQueryValueExW(hKey, NULL, NULL, &valType, valBuf, &valSize) == ERROR_FILE_NOT_FOUND) {
...@@ -444,8 +442,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli ...@@ -444,8 +442,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
result = TRUE; result = TRUE;
done: done:
heap_free(valBuf); free(valBuf);
heap_free(valName); free(valName);
SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0); SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
if (hKey) RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include "wine/debug.h" #include "wine/debug.h"
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define __MAIN_H__ #define __MAIN_H__
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "resource.h" #include "resource.h"
#define STATUS_WINDOW 2001 #define STATUS_WINDOW 2001
...@@ -156,8 +157,6 @@ void WINAPIV output_message(unsigned int id, ...); ...@@ -156,8 +157,6 @@ void WINAPIV output_message(unsigned int id, ...);
void WINAPIV error_exit(unsigned int id, ...); void WINAPIV error_exit(unsigned int id, ...);
/* regproc.c */ /* regproc.c */
void *heap_xalloc(size_t size);
void *heap_xrealloc(void *buf, size_t size);
char *GetMultiByteString(const WCHAR *strW); char *GetMultiByteString(const WCHAR *strW);
BOOL import_registry_file(FILE *reg_file); BOOL import_registry_file(FILE *reg_file);
void delete_registry_key(WCHAR *reg_key_name); void delete_registry_key(WCHAR *reg_key_name);
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <shellapi.h> #include <shellapi.h>
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "main.h" #include "main.h"
WINE_DEFAULT_DEBUG_CHANNEL(regedit); WINE_DEFAULT_DEBUG_CHANNEL(regedit);
...@@ -41,12 +41,12 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen) ...@@ -41,12 +41,12 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen)
* we should call WriteFile() with OEM code page. * we should call WriteFile() with OEM code page.
*/ */
len = WideCharToMultiByte(GetOEMCP(), 0, str, wlen, NULL, 0, NULL, NULL); len = WideCharToMultiByte(GetOEMCP(), 0, str, wlen, NULL, 0, NULL, NULL);
msgA = heap_xalloc(len); msgA = malloc(len);
if (!msgA) return; if (!msgA) return;
WideCharToMultiByte(GetOEMCP(), 0, str, wlen, msgA, len, NULL, NULL); WideCharToMultiByte(GetOEMCP(), 0, str, wlen, msgA, len, NULL, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE);
heap_free(msgA); free(msgA);
} }
} }
...@@ -119,13 +119,13 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i) ...@@ -119,13 +119,13 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
size = SearchPathW(NULL, filename, NULL, 0, NULL, NULL); size = SearchPathW(NULL, filename, NULL, 0, NULL, NULL);
if (size > 0) if (size > 0)
{ {
realname = heap_xalloc(size * sizeof(WCHAR)); realname = malloc(size * sizeof(WCHAR));
size = SearchPathW(NULL, filename, NULL, size, realname, NULL); size = SearchPathW(NULL, filename, NULL, size, realname, NULL);
} }
if (size == 0) if (size == 0)
{ {
output_message(STRING_FILE_NOT_FOUND, filename); output_message(STRING_FILE_NOT_FOUND, filename);
heap_free(realname); free(realname);
return; return;
} }
reg_file = _wfopen(realname, L"rb"); reg_file = _wfopen(realname, L"rb");
...@@ -133,14 +133,14 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i) ...@@ -133,14 +133,14 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
{ {
_wperror(L"regedit"); _wperror(L"regedit");
output_message(STRING_CANNOT_OPEN_FILE, filename); output_message(STRING_CANNOT_OPEN_FILE, filename);
heap_free(realname); free(realname);
return; return;
} }
} }
import_registry_file(reg_file); import_registry_file(reg_file);
if (realname) if (realname)
{ {
heap_free(realname); free(realname);
fclose(reg_file); fclose(reg_file);
} }
break; break;
......
...@@ -25,12 +25,10 @@ ...@@ -25,12 +25,10 @@
#include <windows.h> #include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdlib.h>
#include <wine/debug.h>
#include <shlwapi.h> #include <shlwapi.h>
#include "wine/heap.h"
#include "main.h" #include "main.h"
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(regedit); WINE_DEFAULT_DEBUG_CHANNEL(regedit);
...@@ -82,7 +80,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKe ...@@ -82,7 +80,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKe
} }
*pMaxChars *= 2; *pMaxChars *= 2;
*pKeyPath = heap_xrealloc(*pKeyPath, *pMaxChars); *pKeyPath = realloc(*pKeyPath, *pMaxChars);
} while(TRUE); } while(TRUE);
return TRUE; return TRUE;
...@@ -98,7 +96,7 @@ LPWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey) ...@@ -98,7 +96,7 @@ LPWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
if (!hItem) return NULL; if (!hItem) return NULL;
} }
pathBuffer = heap_xalloc(maxLen * sizeof(WCHAR)); pathBuffer = malloc(maxLen * sizeof(WCHAR));
if (!pathBuffer) return NULL; if (!pathBuffer) return NULL;
*pathBuffer = 0; *pathBuffer = 0;
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL; if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
...@@ -117,7 +115,7 @@ static LPWSTR get_path_component(LPCWSTR *lplpKeyName) { ...@@ -117,7 +115,7 @@ static LPWSTR get_path_component(LPCWSTR *lplpKeyName) {
return NULL; return NULL;
len = lpPos+1-(*lplpKeyName); len = lpPos+1-(*lplpKeyName);
lpResult = heap_xalloc(len * sizeof(WCHAR)); lpResult = malloc(len * sizeof(WCHAR));
lstrcpynW(lpResult, *lplpKeyName, len); lstrcpynW(lpResult, *lplpKeyName, len);
*lplpKeyName = *lpPos ? lpPos+1 : NULL; *lplpKeyName = *lpPos ? lpPos+1 : NULL;
...@@ -152,7 +150,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) { ...@@ -152,7 +150,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem ); SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
if (!lpKeyName) if (!lpKeyName)
{ {
heap_free(lpItemName); free(lpItemName);
return hItem; return hItem;
} }
hOldItem = hItem; hOldItem = hItem;
...@@ -161,7 +159,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) { ...@@ -161,7 +159,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
} }
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem); hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
} }
heap_free(lpItemName); free(lpItemName);
if (!hItem) if (!hItem)
return valid_path ? hOldItem : hRoot; return valid_path ? hOldItem : hRoot;
} }
...@@ -236,17 +234,17 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, ...@@ -236,17 +234,17 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
return FALSE; return FALSE;
if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
heap_free(KeyPath); free(KeyPath);
return FALSE; return FALSE;
} }
heap_free(KeyPath); free(KeyPath);
if (ERROR_SUCCESS != RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &lenNameMax, &lenValueMax, NULL, NULL)) if (ERROR_SUCCESS != RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &lenNameMax, &lenValueMax, NULL, NULL))
return FALSE; return FALSE;
lenName = ++lenNameMax; lenName = ++lenNameMax;
valName = heap_xalloc(lenName * sizeof(WCHAR)); valName = malloc(lenName * sizeof(WCHAR));
adjust = 0; adjust = 0;
...@@ -267,8 +265,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, ...@@ -267,8 +265,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
if (mode & SEARCH_VALUES) { if (mode & SEARCH_VALUES) {
if (match_string(valName, sstring, mode)) { if (match_string(valName, sstring, mode)) {
heap_free(valName); free(valName);
heap_free(buffer); free(buffer);
RegCloseKey(hKey); RegCloseKey(hKey);
*row = i+adjust; *row = i+adjust;
return TRUE; return TRUE;
...@@ -277,15 +275,15 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, ...@@ -277,15 +275,15 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
if ((mode & SEARCH_CONTENT) && (type == REG_EXPAND_SZ || type == REG_SZ)) { if ((mode & SEARCH_CONTENT) && (type == REG_EXPAND_SZ || type == REG_SZ)) {
if (!buffer) if (!buffer)
buffer = heap_xalloc(lenValueMax); buffer = malloc(lenValueMax);
lenName = lenNameMax; lenName = lenNameMax;
lenValue = lenValueMax; lenValue = lenValueMax;
if (ERROR_SUCCESS != RegEnumValueW(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue)) if (ERROR_SUCCESS != RegEnumValueW(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue))
break; break;
if (match_string(buffer, sstring, mode)) { if (match_string(buffer, sstring, mode)) {
heap_free(valName); free(valName);
heap_free(buffer); free(buffer);
RegCloseKey(hKey); RegCloseKey(hKey);
*row = i+adjust; *row = i+adjust;
return TRUE; return TRUE;
...@@ -294,8 +292,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode, ...@@ -294,8 +292,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
i++; i++;
} }
heap_free(valName); free(valName);
heap_free(buffer); free(buffer);
RegCloseKey(hKey); RegCloseKey(hKey);
} }
return FALSE; return FALSE;
...@@ -371,7 +369,7 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) ...@@ -371,7 +369,7 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
} else { } else {
hKey = hRoot; hKey = hRoot;
} }
heap_free(KeyPath); free(KeyPath);
if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) { if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
return FALSE; return FALSE;
...@@ -392,10 +390,10 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) ...@@ -392,10 +390,10 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
} }
dwMaxSubKeyLen++; /* account for the \0 terminator */ dwMaxSubKeyLen++; /* account for the \0 terminator */
Name = heap_xalloc(dwMaxSubKeyLen * sizeof(WCHAR)); Name = malloc(dwMaxSubKeyLen * sizeof(WCHAR));
tvItem.cchTextMax = dwMaxSubKeyLen; tvItem.cchTextMax = dwMaxSubKeyLen;
tvItem.pszText = heap_xalloc(dwMaxSubKeyLen * sizeof(WCHAR)); tvItem.pszText = malloc(dwMaxSubKeyLen * sizeof(WCHAR));
/* Now go through all the children in the registry, and check if any have to be added. */ /* Now go through all the children in the registry, and check if any have to be added. */
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) { for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
...@@ -422,8 +420,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) ...@@ -422,8 +420,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
tvItem.mask = TVIF_TEXT; tvItem.mask = TVIF_TEXT;
tvItem.hItem = childItem; tvItem.hItem = childItem;
if (!TreeView_GetItemW(hwndTV, &tvItem)) { if (!TreeView_GetItemW(hwndTV, &tvItem)) {
heap_free(Name); free(Name);
heap_free(tvItem.pszText); free(tvItem.pszText);
return FALSE; return FALSE;
} }
...@@ -438,8 +436,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem) ...@@ -438,8 +436,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount); AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
} }
} }
heap_free(Name); free(Name);
heap_free(tvItem.pszText); free(tvItem.pszText);
RegCloseKey(hKey); RegCloseKey(hKey);
/* Now go through all the children in the tree, and check if any have to be removed. */ /* Now go through all the children in the tree, and check if any have to be removed. */
...@@ -647,7 +645,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state) ...@@ -647,7 +645,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0); errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
if (errCode != ERROR_SUCCESS) goto done; if (errCode != ERROR_SUCCESS) goto done;
dwMaxSubKeyLen++; /* account for the \0 terminator */ dwMaxSubKeyLen++; /* account for the \0 terminator */
Name = heap_xalloc(dwMaxSubKeyLen * sizeof(WCHAR)); Name = malloc(dwMaxSubKeyLen * sizeof(WCHAR));
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) { for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
DWORD cName = dwMaxSubKeyLen, dwSubCount; DWORD cName = dwMaxSubKeyLen, dwSubCount;
...@@ -663,7 +661,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state) ...@@ -663,7 +661,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount); AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
} }
RegCloseKey(hNewKey); RegCloseKey(hNewKey);
heap_free(Name); free(Name);
done: done:
item.mask = TVIF_STATE; item.mask = TVIF_STATE;
...@@ -674,7 +672,7 @@ done: ...@@ -674,7 +672,7 @@ done:
SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0); SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
SetCursor(hcursorOld); SetCursor(hcursorOld);
expanding = FALSE; expanding = FALSE;
heap_free(keyPath); free(keyPath);
return TRUE; return TRUE;
} }
......
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