[PATCH 1/1] regedit: Replace heap_x*() functions with malloc(), realloc() and free()
Hugh McMaster
wine at gitlab.winehq.org
Thu Jul 7 06:58:15 CDT 2022
From: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/childwnd.c | 29 ++++----
programs/regedit/edit.c | 36 +++++-----
programs/regedit/framewnd.c | 46 +++++++------
programs/regedit/hexedit.c | 25 ++++---
programs/regedit/listview.c | 30 ++++-----
programs/regedit/main.c | 1 -
programs/regedit/main.h | 3 +-
programs/regedit/regedit.c | 14 ++--
programs/regedit/regproc.c | 128 ++++++++++++++----------------------
programs/regedit/treeview.c | 54 ++++++++-------
10 files changed, 163 insertions(+), 203 deletions(-)
diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c
index 704299be837..c243a76c807 100644
--- a/programs/regedit/childwnd.c
+++ b/programs/regedit/childwnd.c
@@ -25,7 +25,6 @@
#include "main.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(regedit);
@@ -99,7 +98,7 @@ static LPWSTR CombinePaths(LPCWSTR pPaths[], int nPaths) {
len += lstrlenW(pPaths[i])+1;
}
}
- combined = heap_xalloc(len * sizeof(WCHAR));
+ combined = malloc(len * sizeof(WCHAR));
*combined = '\0';
for (i=0, pos=0; i<nPaths; i++) {
if (pPaths[i] && *pPaths[i]) {
@@ -122,7 +121,7 @@ static LPWSTR GetPathRoot(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
HKEY hRootKey = NULL;
if (!hItem)
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
- heap_free(GetItemPath(hwndTV, hItem, &hRootKey));
+ free(GetItemPath(hwndTV, hItem, &hRootKey));
if (!bFull && !hRootKey)
return NULL;
if (hRootKey)
@@ -143,8 +142,8 @@ LPWSTR GetItemFullPath(HWND hwndTV, HTREEITEM hItem, BOOL bFull) {
parts[0] = GetPathRoot(hwndTV, hItem, bFull);
parts[1] = GetItemPath(hwndTV, hItem, &hRootKey);
ret = CombinePaths((LPCWSTR *)parts, 2);
- heap_free(parts[0]);
- heap_free(parts[1]);
+ free(parts[0]);
+ free(parts[1]);
return ret;
}
@@ -165,7 +164,7 @@ static void OnTreeSelectionChanged(HWND hwndTV, HWND hwndLV, HTREEITEM hItem, BO
keyPath = GetItemPath(hwndTV, hItem, &hRootKey);
RefreshListView(hwndLV, hRootKey, keyPath, NULL);
- heap_free(keyPath);
+ free(keyPath);
}
UpdateStatusBar();
}
@@ -272,7 +271,7 @@ static void set_last_key(HWND hwndTV)
value = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE);
RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)value, (lstrlenW(value) + 1) * sizeof(WCHAR));
if (selection != root)
- heap_free(value);
+ free(value);
RegCloseKey(hkey);
}
}
@@ -304,7 +303,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
WCHAR *path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
BOOL res = RenameKey(hWnd, hRootKey, path, dispInfo->item.pszText);
- heap_free(path);
+ free(path);
if (res)
{
@@ -317,7 +316,7 @@ static int treeview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
update_listview_path(path);
- heap_free(path);
+ free(path);
UpdateStatusBar();
}
@@ -391,9 +390,9 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
LINE_INFO *info = (LINE_INFO *)nmlv->lParam;
- heap_free(info->name);
- heap_free(info->val);
- heap_free(info);
+ free(info->name);
+ free(info->val);
+ free(info);
break;
}
case LVN_ENDLABELEDITW:
@@ -412,7 +411,7 @@ static int listview_notify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam
dispInfo->item.iItem, (LPARAM)&dispInfo->item);
}
- heap_free(oldName);
+ free(oldName);
return 0;
}
case LVN_GETDISPINFOW:
@@ -440,7 +439,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
{
switch (message) {
case WM_CREATE:
- g_pChildWnd = heap_xalloc(sizeof(ChildWnd));
+ g_pChildWnd = malloc(sizeof(ChildWnd));
if (!g_pChildWnd) return 0;
LoadStringW(hInst, IDS_REGISTRY_ROOT_NAME, g_pChildWnd->szPath, MAX_PATH);
g_pChildWnd->nSplitPos = 250;
@@ -472,7 +471,7 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
goto def;
case WM_DESTROY:
set_last_key(g_pChildWnd->hTreeWnd);
- heap_free(g_pChildWnd);
+ free(g_pChildWnd);
g_pChildWnd = NULL;
PostQuitMessage(0);
break;
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c
index 330b535d732..4cb48799090 100644
--- a/programs/regedit/edit.c
+++ b/programs/regedit/edit.c
@@ -24,11 +24,9 @@
#include <commctrl.h>
#include <commdlg.h>
#include <cderr.h>
-#include <stdlib.h>
#include <shellapi.h>
#include <shlwapi.h>
-#include "wine/heap.h"
#include "main.h"
static const WCHAR* editValueName;
@@ -120,7 +118,7 @@ static INT_PTR CALLBACK modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case IDOK:
if ((hwndValue = GetDlgItem(hwndDlg, IDC_VALUE_DATA))) {
len = GetWindowTextLengthW(hwndValue);
- stringValueData = heap_xrealloc(stringValueData, (len + 1) * sizeof(WCHAR));
+ stringValueData = realloc(stringValueData, (len + 1) * sizeof(WCHAR));
if (!GetWindowTextW(hwndValue, stringValueData, len + 1))
*stringValueData = 0;
}
@@ -156,11 +154,11 @@ static INT_PTR CALLBACK bin_modify_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wPara
case IDOK:
params = (struct edit_params *)GetWindowLongPtrW(hwndDlg, DWLP_USER);
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);
lRet = RegSetValueExW(params->hkey, params->value_name, 0, params->type, data, size);
- heap_free(data);
+ free(data);
if (lRet == ERROR_SUCCESS)
EndDialog(hwndDlg, 1);
@@ -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 (len) *len = 1;
if (lpType) *lpType = REG_SZ;
- buffer = heap_xalloc(sizeof(WCHAR));
+ buffer = malloc(sizeof(WCHAR));
*buffer = '\0';
return buffer;
}
@@ -197,7 +195,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
goto done;
}
- buffer = heap_xalloc(valueDataLen + sizeof(WCHAR));
+ buffer = malloc(valueDataLen + sizeof(WCHAR));
lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)buffer, &valueDataLen);
if (lRet) {
error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
@@ -209,7 +207,7 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
return buffer;
done:
- heap_free(buffer);
+ free(buffer);
return NULL;
}
@@ -277,7 +275,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
}
} else if ( type == REG_DWORD ) {
DWORD value = *((DWORD*)stringValueData);
- stringValueData = heap_xrealloc(stringValueData, 64);
+ stringValueData = realloc(stringValueData, 64);
wsprintfW(stringValueData, L"%x", value);
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)
}
} else if ( type == REG_QWORD ) {
UINT64 value = *((UINT64 *)stringValueData);
- stringValueData = heap_xrealloc(stringValueData, 64);
+ stringValueData = realloc(stringValueData, 64);
swprintf(stringValueData, 64, L"%I64x", value);
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)
for (i = 0, count = 0; i < len / sizeof(WCHAR); i++)
if ( !stringValueData[i] && stringValueData[i + 1] )
count++;
- tmpValueData = heap_xalloc(len + (count * sizeof(WCHAR)));
+ tmpValueData = malloc(len + (count * sizeof(WCHAR)));
for ( i = 0, j = 0; i < len / sizeof(WCHAR); i++)
{
@@ -323,14 +321,14 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
tmpValueData[j++] = stringValueData[i];
}
- heap_free(stringValueData);
+ free(stringValueData);
stringValueData = tmpValueData;
tmpValueData = NULL;
if (DialogBoxW(0, MAKEINTRESOURCEW(IDD_EDIT_MULTI_STRING), hwnd, modify_dlgproc) == IDOK)
{
len = lstrlenW( stringValueData );
- tmpValueData = heap_xalloc((len + 2) * sizeof(WCHAR));
+ tmpValueData = malloc((len + 2) * sizeof(WCHAR));
for (i = 0, j = 0; i < len; i++)
{
@@ -346,7 +344,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
tmpValueData[j++] = 0;
tmpValueData[j++] = 0;
- heap_free(stringValueData);
+ free(stringValueData);
stringValueData = tmpValueData;
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)
{
int index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1,
MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
- heap_free(stringValueData);
+ free(stringValueData);
stringValueData = read_value(hwnd, hKey, valueName, &type, &len);
format_value_data(g_pChildWnd->hListWnd, index, type, stringValueData, len);
}
done:
- heap_free(stringValueData);
+ free(stringValueData);
stringValueData = NULL;
RegCloseKey(hKey);
return result;
@@ -538,7 +536,7 @@ BOOL RenameValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR oldName, LPC
result = TRUE;
done:
- heap_free(value);
+ free(value);
RegCloseKey(hKey);
return result;
}
@@ -562,7 +560,7 @@ BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName)
} else {
LPWSTR srcSubKey_copy;
- parentPath = heap_xalloc((lstrlenW(keyPath) + 1) * sizeof(WCHAR));
+ parentPath = malloc((lstrlenW(keyPath) + 1) * sizeof(WCHAR));
lstrcpyW(parentPath, keyPath);
srcSubKey_copy = wcsrchr(parentPath, '\\');
*srcSubKey_copy = 0;
@@ -607,7 +605,7 @@ done:
RegCloseKey(destKey);
if (parentKey) {
RegCloseKey(parentKey);
- heap_free(parentPath);
+ free(parentPath);
}
return result;
}
diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c
index c9eb2c4c469..d821d4dad77 100644
--- a/programs/regedit/framewnd.c
+++ b/programs/regedit/framewnd.c
@@ -24,12 +24,10 @@
#include <commctrl.h>
#include <commdlg.h>
#include <cderr.h>
-#include <stdlib.h>
#include <shellapi.h>
#include "main.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(regedit);
@@ -188,7 +186,7 @@ static void UpdateMenuItems(HMENU hMenu) {
EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE,
(GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
- heap_free(keyName);
+ free(keyName);
}
static void add_remove_modify_menu_items(HMENU hMenu)
@@ -227,7 +225,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList)
if (!num_values) goto exit;
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);
@@ -244,7 +242,7 @@ static int add_favourite_key_items(HMENU hMenu, HWND hList)
}
}
- heap_free(value_name);
+ free(value_name);
exit:
RegCloseKey(hkey);
return i;
@@ -303,7 +301,7 @@ void UpdateStatusBar(void)
{
LPWSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, TRUE);
SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
- heap_free(fullPath);
+ free(fullPath);
}
static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
@@ -361,12 +359,12 @@ static void ExportRegistryFile_StoreSelection(HWND hdlg, OPENFILENAMEW *pOpenFil
if (IsDlgButtonChecked(hdlg, IDC_EXPORT_SELECTED))
{
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);
}
else
{
- pOpenFileName->lCustData = (LPARAM)heap_xalloc(sizeof(WCHAR));
+ pOpenFileName->lCustData = (LPARAM)malloc(sizeof(WCHAR));
*(WCHAR *)pOpenFileName->lCustData = 0;
}
}
@@ -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);
if (path && path[0])
export_branch = TRUE;
- heap_free(path);
+ free(path);
CheckRadioButton(hdlg, IDC_EXPORT_ALL, IDC_EXPORT_SELECTED, export_branch ? IDC_EXPORT_SELECTED : IDC_EXPORT_ALL);
break;
}
@@ -481,7 +479,7 @@ static BOOL ImportRegistryFile(HWND hWnd)
key_path = GetItemPath(g_pChildWnd->hTreeWnd, 0, &root_key);
RefreshListView(g_pChildWnd->hListWnd, root_key, key_path, NULL);
- heap_free(key_path);
+ free(key_path);
return TRUE;
}
@@ -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 len = SendMessageW(hwndList, LB_GETTEXTLEN, pos, 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);
if (len>127)
lpName[127] = '\0';
lstrcpyW(favoriteName, lpName);
EndDialog(hwndDlg, IDOK);
- heap_free(lpName);
+ free(lpName);
}
return TRUE;
}
@@ -795,7 +793,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} else if (DeleteKey(hWnd, hKeyRoot, keyPath)) {
DeleteNode(g_pChildWnd->hTreeWnd, 0);
}
- heap_free(keyPath);
+ free(keyPath);
} else if (hWndDelete == g_pChildWnd->hListWnd) {
unsigned int num_selected, index, focus_idx;
WCHAR *keyPath;
@@ -822,10 +820,10 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR *valueName = GetItemText(g_pChildWnd->hListWnd, index);
if (!DeleteValue(hWnd, hKeyRoot, keyPath, valueName))
{
- heap_free(valueName);
+ free(valueName);
break;
}
- heap_free(valueName);
+ free(valueName);
SendMessageW(g_pChildWnd->hListWnd, LVM_DELETEITEM, index, 0L);
/* the default value item is always visible, so add it back in */
if (!index)
@@ -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));
}
- heap_free(keyPath);
+ free(keyPath);
} else if (IsChild(g_pChildWnd->hTreeWnd, hWndDelete) ||
IsChild(g_pChildWnd->hListWnd, hWndDelete)) {
SendMessageW(hWndDelete, WM_KEYDOWN, VK_DELETE, 0);
@@ -853,8 +851,8 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR *valueName = GetValueName(g_pChildWnd->hListWnd);
WCHAR *keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
ModifyValue(hWnd, hKeyRoot, keyPath, valueName);
- heap_free(keyPath);
- heap_free(valueName);
+ free(keyPath);
+ free(valueName);
break;
}
case ID_EDIT_FIND:
@@ -901,7 +899,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
LPWSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
if (fullPath) {
CopyKeyName(hWnd, fullPath);
- heap_free(fullPath);
+ free(fullPath);
}
break;
}
@@ -913,7 +911,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (InsertNode(g_pChildWnd->hTreeWnd, 0, newKeyW))
StartKeyRename(g_pChildWnd->hTreeWnd);
}
- heap_free(keyPath);
+ free(keyPath);
}
break;
case ID_EDIT_NEW_STRINGVALUE:
@@ -940,7 +938,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR newKey[MAX_NEW_KEY_LEN];
if (CreateValue(hWnd, hKeyRoot, keyPath, valueType, newKey))
StartValueRename(g_pChildWnd->hListWnd);
- heap_free(keyPath);
+ free(keyPath);
}
break;
case ID_EDIT_RENAME:
@@ -954,7 +952,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
} else if (GetFocus() == g_pChildWnd->hListWnd) {
StartValueRename(g_pChildWnd->hListWnd);
}
- heap_free(keyPath);
+ free(keyPath);
break;
}
case ID_TREE_EXPAND_COLLAPSE:
@@ -987,7 +985,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
RegCloseKey(hKey);
}
}
- heap_free(lpKeyPath);
+ free(lpKeyPath);
}
break;
}
@@ -1008,7 +1006,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
WCHAR* keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
RefreshTreeView(g_pChildWnd->hTreeWnd);
RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, NULL);
- heap_free(keyPath);
+ free(keyPath);
}
break;
/*case ID_OPTIONS_TOOLBAR:*/
diff --git a/programs/regedit/hexedit.c b/programs/regedit/hexedit.c
index 8227f201c29..d29c916918e 100644
--- a/programs/regedit/hexedit.c
+++ b/programs/regedit/hexedit.c
@@ -34,7 +34,6 @@
#include "winnls.h"
#include "commctrl.h"
-#include "wine/heap.h"
#include "main.h"
/* spaces dividing hex and ASCII */
@@ -71,7 +70,7 @@ static inline BYTE hexchar_to_byte(WCHAR ch)
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;
wsprintfW(lpszLine, L"%04X ", offset);
@@ -133,7 +132,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
TextOutW(hdc, nXStart, nYStart, lpszLine, lstrlenW(lpszLine));
nYStart += infoPtr->nHeight;
- heap_free(lpszLine);
+ free(lpszLine);
}
SelectObject(hdc, hOldFont);
@@ -172,7 +171,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
if (!nLineLen) size.cx = 0;
- heap_free(lpszLine);
+ free(lpszLine);
SetCaretPos(
GetSystemMetrics(SM_CXBORDER) + size.cx,
@@ -224,10 +223,10 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
static LRESULT
HexEdit_SetData(HEXEDIT_INFO *infoPtr, INT cbData, const BYTE *pData)
{
- heap_free(infoPtr->pData);
+ free(infoPtr->pData);
infoPtr->cbData = 0;
- infoPtr->pData = heap_xalloc(cbData);
+ infoPtr->pData = malloc(cbData);
memcpy(infoPtr->pData, pData, cbData);
infoPtr->cbData = cbData;
@@ -286,7 +285,7 @@ HexEdit_Char (HEXEDIT_INFO *infoPtr, WCHAR ch)
{
/* make room for another byte */
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 */
memmove(infoPtr->pData + nCaretBytePos + 1,
@@ -328,9 +327,9 @@ static inline LRESULT
HexEdit_Destroy (HEXEDIT_INFO *infoPtr)
{
HWND hwnd = infoPtr->hwndSelf;
- heap_free(infoPtr->pData);
+ free(infoPtr->pData);
/* free info data */
- heap_free(infoPtr);
+ free(infoPtr);
SetWindowLongPtrW(hwnd, 0, 0);
return 0;
}
@@ -430,7 +429,7 @@ static inline LRESULT HexEdit_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs)
lpcs->dwExStyle | WS_EX_CLIENTEDGE);
/* allocate memory for info structure */
- infoPtr = heap_xalloc(sizeof(HEXEDIT_INFO));
+ infoPtr = malloc(sizeof(HEXEDIT_INFO));
memset(infoPtr, 0, sizeof(HEXEDIT_INFO));
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
@@ -479,15 +478,15 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
for (i = 0; ; i++)
{
- BYTE *pData = heap_xalloc(i);
+ BYTE *pData = malloc(i);
WCHAR *lpszLine;
SIZE size;
memset(pData, 0, i);
lpszLine = HexEdit_GetLineText(0, pData, i, 0);
GetTextExtentPoint32W(hdc, lpszLine, lstrlenW(lpszLine), &size);
- heap_free(lpszLine);
- heap_free(pData);
+ free(lpszLine);
+ free(pData);
if (size.cx > (rcClient.right - rcClient.left))
{
infoPtr->nBytesPerLine = i - 1;
diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c
index 8e40d488b15..159efc0218f 100644
--- a/programs/regedit/listview.c
+++ b/programs/regedit/listview.c
@@ -22,10 +22,8 @@
#include <windows.h>
#include <winternl.h>
#include <commctrl.h>
-#include <stdlib.h>
#include "main.h"
-#include "wine/heap.h"
static INT Image_String;
static INT Image_Binary;
@@ -50,14 +48,14 @@ LPWSTR GetItemText(HWND hwndLV, UINT item)
unsigned int maxLen = 128;
if (item == 0) return NULL; /* first item is ALWAYS a default */
- curStr = heap_xalloc(maxLen * sizeof(WCHAR));
+ curStr = malloc(maxLen * sizeof(WCHAR));
do {
ListView_GetItemTextW(hwndLV, item, 0, curStr, maxLen);
if (lstrlenW(curStr) < maxLen - 1) return curStr;
maxLen *= 2;
- curStr = heap_xrealloc(curStr, maxLen * sizeof(WCHAR));
+ curStr = realloc(curStr, maxLen * sizeof(WCHAR));
} while (TRUE);
- heap_free(curStr);
+ free(curStr);
return NULL;
}
@@ -73,9 +71,9 @@ WCHAR *GetValueName(HWND hwndLV)
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);
return TRUE;
@@ -136,12 +134,12 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz
{
unsigned int i;
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++)
wsprintfW( strBinary + i*3, L"%02X ", pData[i] );
strBinary[size * 3] = 0;
ListView_SetItemTextW(hwndLV, index, 2, strBinary);
- heap_free(strBinary);
+ free(strBinary);
break;
}
}
@@ -153,20 +151,20 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR
LVITEMW item = { 0 };
int index;
- linfo = heap_xalloc(sizeof(LINE_INFO));
+ linfo = malloc(sizeof(LINE_INFO));
linfo->dwValType = dwValType;
linfo->val_len = dwCount;
if (Name)
{
- linfo->name = heap_xalloc((lstrlenW(Name) + 1) * sizeof(WCHAR));
+ linfo->name = malloc((lstrlenW(Name) + 1) * sizeof(WCHAR));
lstrcpyW(linfo->name, Name);
}
else linfo->name = NULL;
if (ValBuf && dwCount)
{
- linfo->val = heap_xalloc(dwCount);
+ linfo->val = malloc(dwCount);
memcpy(linfo->val, ValBuf, dwCount);
}
else linfo->val = NULL;
@@ -411,8 +409,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
max_val_name_len++;
max_val_size++;
- valName = heap_xalloc(max_val_name_len * sizeof(WCHAR));
- valBuf = heap_xalloc(max_val_size);
+ valName = malloc(max_val_name_len * sizeof(WCHAR));
+ valBuf = malloc(max_val_size);
valSize = max_val_size;
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
result = TRUE;
done:
- heap_free(valBuf);
- heap_free(valName);
+ free(valBuf);
+ free(valName);
SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
if (hKey) RegCloseKey(hKey);
diff --git a/programs/regedit/main.c b/programs/regedit/main.c
index ecc06a5280e..e776ec9d0f7 100644
--- a/programs/regedit/main.c
+++ b/programs/regedit/main.c
@@ -21,7 +21,6 @@
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#include <windows.h>
#include <commctrl.h>
-#include <stdlib.h>
#include <fcntl.h>
#include "wine/debug.h"
diff --git a/programs/regedit/main.h b/programs/regedit/main.h
index 6ad7835e4df..310469f83f6 100644
--- a/programs/regedit/main.h
+++ b/programs/regedit/main.h
@@ -22,6 +22,7 @@
#define __MAIN_H__
#include <stdio.h>
+#include <stdlib.h>
#include "resource.h"
#define STATUS_WINDOW 2001
@@ -156,8 +157,6 @@ void WINAPIV output_message(unsigned int id, ...);
void WINAPIV error_exit(unsigned int id, ...);
/* regproc.c */
-void *heap_xalloc(size_t size);
-void *heap_xrealloc(void *buf, size_t size);
char *GetMultiByteString(const WCHAR *strW);
BOOL import_registry_file(FILE *reg_file);
void delete_registry_key(WCHAR *reg_key_name);
diff --git a/programs/regedit/regedit.c b/programs/regedit/regedit.c
index cc31f83c903..03e0ec9c7cb 100644
--- a/programs/regedit/regedit.c
+++ b/programs/regedit/regedit.c
@@ -22,8 +22,8 @@
#include <windows.h>
#include <commctrl.h>
#include <shellapi.h>
+
#include "wine/debug.h"
-#include "wine/heap.h"
#include "main.h"
WINE_DEFAULT_DEBUG_CHANNEL(regedit);
@@ -41,12 +41,12 @@ static void output_writeconsole(const WCHAR *str, DWORD wlen)
* we should call WriteFile() with OEM code page.
*/
len = WideCharToMultiByte(GetOEMCP(), 0, str, wlen, NULL, 0, NULL, NULL);
- msgA = heap_xalloc(len);
+ msgA = malloc(len);
if (!msgA) return;
WideCharToMultiByte(GetOEMCP(), 0, str, wlen, msgA, len, NULL, NULL);
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)
size = SearchPathW(NULL, filename, NULL, 0, NULL, NULL);
if (size > 0)
{
- realname = heap_xalloc(size * sizeof(WCHAR));
+ realname = malloc(size * sizeof(WCHAR));
size = SearchPathW(NULL, filename, NULL, size, realname, NULL);
}
if (size == 0)
{
output_message(STRING_FILE_NOT_FOUND, filename);
- heap_free(realname);
+ free(realname);
return;
}
reg_file = _wfopen(realname, L"rb");
@@ -133,14 +133,14 @@ static void PerformRegAction(REGEDIT_ACTION action, WCHAR **argv, int *i)
{
_wperror(L"regedit");
output_message(STRING_CANNOT_OPEN_FILE, filename);
- heap_free(realname);
+ free(realname);
return;
}
}
import_registry_file(reg_file);
if (realname)
{
- heap_free(realname);
+ free(realname);
fclose(reg_file);
}
break;
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 9dea3ebd446..4f84c5883be 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -22,16 +22,12 @@
*/
#include <errno.h>
-#include <stdlib.h>
#include <fcntl.h>
#include <io.h>
#include <windows.h>
#include <commctrl.h>
-#include <wine/debug.h>
-#include <wine/heap.h>
-#include "main.h"
-WINE_DEFAULT_DEBUG_CHANNEL(regedit);
+#include "main.h"
#define REG_VAL_BUF_SIZE 4096
@@ -40,30 +36,6 @@ static HKEY reg_class_keys[] = {
HKEY_CURRENT_CONFIG, HKEY_CURRENT_USER, HKEY_DYN_DATA
};
-void *heap_xalloc(size_t size)
-{
- void *buf = heap_alloc(size);
- if (!buf)
- {
- ERR("Out of memory!\n");
- exit(1);
- }
- return buf;
-}
-
-void *heap_xrealloc(void *buf, size_t size)
-{
- void *new_buf = heap_realloc(buf, size);
-
- if (!new_buf)
- {
- ERR("Out of memory!\n");
- exit(1);
- }
-
- return new_buf;
-}
-
/******************************************************************************
* Allocates memory and converts input from multibyte to wide chars
* Returned string must be freed by the caller
@@ -75,7 +47,7 @@ static WCHAR* GetWideString(const char* strA)
WCHAR* strW;
int len = MultiByteToWideChar(CP_ACP, 0, strA, -1, NULL, 0);
- strW = heap_xalloc(len * sizeof(WCHAR));
+ strW = malloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, strA, -1, strW, len);
return strW;
}
@@ -93,7 +65,7 @@ static WCHAR* GetWideStringN(const char* strA, int chars, DWORD *len)
WCHAR* strW;
*len = MultiByteToWideChar(CP_ACP, 0, strA, chars, NULL, 0);
- strW = heap_xalloc(*len * sizeof(WCHAR));
+ strW = malloc(*len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, strA, chars, strW, *len);
return strW;
}
@@ -112,7 +84,7 @@ char* GetMultiByteString(const WCHAR* strW)
char* strA;
int len = WideCharToMultiByte(CP_ACP, 0, strW, -1, NULL, 0, NULL, NULL);
- strA = heap_xalloc(len);
+ strA = malloc(len);
WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, len, NULL, NULL);
return strA;
}
@@ -130,7 +102,7 @@ static char* GetMultiByteStringN(const WCHAR* strW, int chars, DWORD* len)
char* strA;
*len = WideCharToMultiByte(CP_ACP, 0, strW, chars, NULL, 0, NULL, NULL);
- strA = heap_xalloc(*len);
+ strA = malloc(*len);
WideCharToMultiByte(CP_ACP, 0, strW, chars, strA, *len, NULL, NULL);
return strA;
}
@@ -277,7 +249,7 @@ static BOOL convert_hex_csv_to_hex(struct parser *parser, WCHAR **str)
/* The worst case is 1 digit + 1 comma per byte */
size = ((lstrlenW(*str) + 1) / 2) + parser->data_size;
- parser->data = heap_xrealloc(parser->data, size);
+ parser->data = realloc(parser->data, size);
s = *str;
d = (BYTE *)parser->data + parser->data_size;
@@ -447,7 +419,7 @@ static void close_key(struct parser *parser)
{
if (parser->hkey)
{
- heap_free(parser->key_name);
+ free(parser->key_name);
parser->key_name = NULL;
RegCloseKey(parser->hkey);
@@ -476,7 +448,7 @@ static LONG open_key(struct parser *parser, WCHAR *path)
if (res == ERROR_SUCCESS)
{
- parser->key_name = heap_xalloc((lstrlenW(path) + 1) * sizeof(WCHAR));
+ parser->key_name = malloc((lstrlenW(path) + 1) * sizeof(WCHAR));
lstrcpyW(parser->key_name, path);
}
else
@@ -488,7 +460,7 @@ static LONG open_key(struct parser *parser, WCHAR *path)
static void free_parser_data(struct parser *parser)
{
if (parser->parse_type == REG_DWORD || parser->parse_type == REG_BINARY)
- heap_free(parser->data);
+ free(parser->data);
parser->data = NULL;
parser->data_size = 0;
@@ -522,7 +494,7 @@ static void prepare_hex_string_data(struct parser *parser)
parser->data = GetWideStringN(parser->data, parser->data_size, &parser->data_size);
parser->data_size *= sizeof(WCHAR);
- heap_free(data);
+ free(data);
}
}
}
@@ -571,12 +543,12 @@ static WCHAR *header_state(struct parser *parser, WCHAR *pos)
if (!parser->is_unicode)
{
- header = heap_xalloc((lstrlenW(line) + 3) * sizeof(WCHAR));
+ header = malloc((lstrlenW(line) + 3) * sizeof(WCHAR));
header[0] = parser->two_wchars[0];
header[1] = parser->two_wchars[1];
lstrcpyW(header + 2, line);
parser->reg_version = parse_file_header(header);
- heap_free(header);
+ free(header);
}
else parser->reg_version = parse_file_header(line);
@@ -708,7 +680,7 @@ static WCHAR *delete_key_state(struct parser *parser, WCHAR *pos)
/* handler for parser DEFAULT_VALUE_NAME state */
static WCHAR *default_value_name_state(struct parser *parser, WCHAR *pos)
{
- heap_free(parser->value_name);
+ free(parser->value_name);
parser->value_name = NULL;
set_state(parser, DATA_START);
@@ -720,14 +692,14 @@ static WCHAR *quoted_value_name_state(struct parser *parser, WCHAR *pos)
{
WCHAR *val_name = pos, *p;
- heap_free(parser->value_name);
+ free(parser->value_name);
parser->value_name = NULL;
if (!REGPROC_unescape_string(val_name, &p))
goto invalid;
/* copy the value name in case we need to parse multiple lines and the buffer is overwritten */
- parser->value_name = heap_xalloc((lstrlenW(val_name) + 1) * sizeof(WCHAR));
+ parser->value_name = malloc((lstrlenW(val_name) + 1) * sizeof(WCHAR));
lstrcpyW(parser->value_name, val_name);
set_state(parser, DATA_START);
@@ -838,7 +810,7 @@ static WCHAR *dword_data_state(struct parser *parser, WCHAR *pos)
{
WCHAR *line = pos;
- parser->data = heap_xalloc(sizeof(DWORD));
+ parser->data = malloc(sizeof(DWORD));
if (!convert_hex_to_dword(line, parser->data))
goto invalid;
@@ -958,14 +930,14 @@ static WCHAR *get_lineA(FILE *fp)
static char *buf, *next;
char *line;
- heap_free(lineW);
+ free(lineW);
if (!fp) goto cleanup;
if (!size)
{
size = REG_VAL_BUF_SIZE;
- buf = heap_xalloc(size);
+ buf = malloc(size);
*buf = 0;
next = buf;
}
@@ -982,7 +954,7 @@ static WCHAR *get_lineA(FILE *fp)
if (size - len < 3)
{
size *= 2;
- buf = heap_xrealloc(buf, size);
+ buf = realloc(buf, size);
}
if (!(count = fread(buf + len, 1, size - len - 1, fp)))
{
@@ -1004,7 +976,7 @@ static WCHAR *get_lineA(FILE *fp)
cleanup:
lineW = NULL;
- if (size) heap_free(buf);
+ if (size) free(buf);
size = 0;
return NULL;
}
@@ -1020,7 +992,7 @@ static WCHAR *get_lineW(FILE *fp)
if (!size)
{
size = REG_VAL_BUF_SIZE;
- buf = heap_xalloc(size * sizeof(WCHAR));
+ buf = malloc(size * sizeof(WCHAR));
*buf = 0;
next = buf;
}
@@ -1037,7 +1009,7 @@ static WCHAR *get_lineW(FILE *fp)
if (size - len < 3)
{
size *= 2;
- buf = heap_xrealloc(buf, size * sizeof(WCHAR));
+ buf = realloc(buf, size * sizeof(WCHAR));
}
if (!(count = fread(buf + len, sizeof(WCHAR), size - len - 1, fp)))
{
@@ -1056,7 +1028,7 @@ static WCHAR *get_lineW(FILE *fp)
}
cleanup:
- if (size) heap_free(buf);
+ if (size) free(buf);
size = 0;
return NULL;
}
@@ -1099,7 +1071,7 @@ BOOL import_registry_file(FILE *reg_file)
if (parser.reg_version == REG_VERSION_FUZZY || parser.reg_version == REG_VERSION_INVALID)
return parser.reg_version == REG_VERSION_FUZZY;
- heap_free(parser.value_name);
+ free(parser.value_name);
close_key(&parser);
return TRUE;
@@ -1140,7 +1112,7 @@ static void REGPROC_write_line(FILE *fp, const WCHAR *str, BOOL unicode)
{
char *strA = GetMultiByteString(str);
fputs(strA, fp);
- heap_free(strA);
+ free(strA);
}
}
@@ -1159,7 +1131,7 @@ static WCHAR *REGPROC_escape_string(WCHAR *str, size_t str_len, size_t *line_len
escape_count++;
}
- buf = heap_xalloc((str_len + escape_count + 1) * sizeof(WCHAR));
+ buf = malloc((str_len + escape_count + 1) * sizeof(WCHAR));
for (i = 0, pos = 0; i < str_len; i++, pos++)
{
@@ -1203,11 +1175,11 @@ static size_t export_value_name(FILE *fp, WCHAR *name, size_t len, BOOL unicode)
if (name && *name)
{
WCHAR *str = REGPROC_escape_string(name, len, &line_len);
- WCHAR *buf = heap_xalloc((line_len + 4) * sizeof(WCHAR));
+ WCHAR *buf = malloc((line_len + 4) * sizeof(WCHAR));
line_len = swprintf(buf, line_len + 4, L"\"%s\"=", str);
REGPROC_write_line(fp, buf, unicode);
- heap_free(buf);
- heap_free(str);
+ free(buf);
+ free(str);
}
else
{
@@ -1226,14 +1198,14 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size)
if (size)
len = size / sizeof(WCHAR) - 1;
str = REGPROC_escape_string(data, len, &line_len);
- *buf = heap_xalloc((line_len + 3) * sizeof(WCHAR));
+ *buf = malloc((line_len + 3) * sizeof(WCHAR));
swprintf(*buf, line_len + 3, L"\"%s\"", str);
- heap_free(str);
+ free(str);
}
static void export_dword_data(WCHAR **buf, DWORD *data)
{
- *buf = heap_xalloc(15 * sizeof(WCHAR));
+ *buf = malloc(15 * sizeof(WCHAR));
swprintf(*buf, 15, L"dword:%08x", *data);
}
@@ -1249,10 +1221,10 @@ static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode)
}
else
{
- WCHAR *buf = heap_xalloc(15 * sizeof(WCHAR));
+ WCHAR *buf = malloc(15 * sizeof(WCHAR));
line_len = swprintf(buf, 15, L"hex(%x):", type);
REGPROC_write_line(fp, buf, unicode);
- heap_free(buf);
+ free(buf);
}
return line_len;
@@ -1273,7 +1245,7 @@ static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len,
data = GetMultiByteStringN(data, size / sizeof(WCHAR), &size);
num_commas = size - 1;
- *buf = heap_xalloc(size * 3 * sizeof(WCHAR));
+ *buf = malloc(size * 3 * sizeof(WCHAR));
for (i = 0, pos = 0; i < size; i++)
{
@@ -1328,7 +1300,7 @@ static void export_data(FILE *fp, WCHAR *value_name, DWORD value_len, DWORD type
if (size || type == REG_SZ)
{
REGPROC_write_line(fp, buf, unicode);
- heap_free(buf);
+ free(buf);
}
export_newline(fp, unicode);
@@ -1338,7 +1310,7 @@ static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name,
{
WCHAR *subkey_path;
- subkey_path = heap_xalloc((path_len + subkey_len + 2) * sizeof(WCHAR));
+ subkey_path = malloc((path_len + subkey_len + 2) * sizeof(WCHAR));
swprintf(subkey_path, path_len + subkey_len + 2, L"%s\\%s", path, subkey_name);
return subkey_path;
@@ -1348,10 +1320,10 @@ static void export_key_name(FILE *fp, WCHAR *name, BOOL unicode)
{
WCHAR *buf;
- buf = heap_xalloc((lstrlenW(name) + 7) * sizeof(WCHAR));
+ buf = malloc((lstrlenW(name) + 7) * sizeof(WCHAR));
swprintf(buf, lstrlenW(name) + 7, L"\r\n[%s]\r\n", name);
REGPROC_write_line(fp, buf, unicode);
- heap_free(buf);
+ free(buf);
}
#define MAX_SUBKEY_LEN 257
@@ -1369,8 +1341,8 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
export_key_name(fp, path, unicode);
- value_name = heap_xalloc(max_value_len * sizeof(WCHAR));
- data = heap_xalloc(max_data_bytes);
+ value_name = malloc(max_value_len * sizeof(WCHAR));
+ data = malloc(max_data_bytes);
i = 0;
for (;;)
@@ -1388,21 +1360,21 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
if (data_size > max_data_bytes)
{
max_data_bytes = data_size;
- data = heap_xrealloc(data, max_data_bytes);
+ data = realloc(data, max_data_bytes);
}
else
{
max_value_len *= 2;
- value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR));
+ value_name = realloc(value_name, max_value_len * sizeof(WCHAR));
}
}
else break;
}
- heap_free(data);
- heap_free(value_name);
+ free(data);
+ free(value_name);
- subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR));
+ subkey_name = malloc(MAX_SUBKEY_LEN * sizeof(WCHAR));
path_len = lstrlenW(path);
@@ -1419,13 +1391,13 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
export_registry_data(fp, subkey, subkey_path, unicode);
RegCloseKey(subkey);
}
- heap_free(subkey_path);
+ free(subkey_path);
i++;
}
else break;
}
- heap_free(subkey_name);
+ free(subkey_name);
return 0;
}
@@ -1516,12 +1488,12 @@ static BOOL export_all(WCHAR *file_name, WCHAR *path, BOOL unicode)
return FALSE;
}
- class_name = heap_xalloc((lstrlenW(reg_class_namesW[i]) + 1) * sizeof(WCHAR));
+ class_name = malloc((lstrlenW(reg_class_namesW[i]) + 1) * sizeof(WCHAR));
lstrcpyW(class_name, reg_class_namesW[i]);
export_registry_data(fp, classes[i], class_name, unicode);
- heap_free(class_name);
+ free(class_name);
RegCloseKey(key);
}
diff --git a/programs/regedit/treeview.c b/programs/regedit/treeview.c
index 5ba4628681a..cd80449999a 100644
--- a/programs/regedit/treeview.c
+++ b/programs/regedit/treeview.c
@@ -25,12 +25,10 @@
#include <windows.h>
#include <commctrl.h>
-#include <stdlib.h>
-#include <wine/debug.h>
#include <shlwapi.h>
-#include "wine/heap.h"
#include "main.h"
+#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(regedit);
@@ -82,7 +80,7 @@ static BOOL get_item_path(HWND hwndTV, HTREEITEM hItem, HKEY* phKey, LPWSTR* pKe
}
*pMaxChars *= 2;
- *pKeyPath = heap_xrealloc(*pKeyPath, *pMaxChars);
+ *pKeyPath = realloc(*pKeyPath, *pMaxChars);
} while(TRUE);
return TRUE;
@@ -98,7 +96,7 @@ LPWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
if (!hItem) return NULL;
}
- pathBuffer = heap_xalloc(maxLen * sizeof(WCHAR));
+ pathBuffer = malloc(maxLen * sizeof(WCHAR));
if (!pathBuffer) return NULL;
*pathBuffer = 0;
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
@@ -117,7 +115,7 @@ static LPWSTR get_path_component(LPCWSTR *lplpKeyName) {
return NULL;
len = lpPos+1-(*lplpKeyName);
- lpResult = heap_xalloc(len * sizeof(WCHAR));
+ lpResult = malloc(len * sizeof(WCHAR));
lstrcpynW(lpResult, *lplpKeyName, len);
*lplpKeyName = *lpPos ? lpPos+1 : NULL;
@@ -152,7 +150,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
if (!lpKeyName)
{
- heap_free(lpItemName);
+ free(lpItemName);
return hItem;
}
hOldItem = hItem;
@@ -161,7 +159,7 @@ HTREEITEM FindPathInTree(HWND hwndTV, LPCWSTR lpKeyName) {
}
hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hItem);
}
- heap_free(lpItemName);
+ free(lpItemName);
if (!hItem)
return valid_path ? hOldItem : hRoot;
}
@@ -236,17 +234,17 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
return FALSE;
if (RegOpenKeyExW(hRoot, KeyPath, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
- heap_free(KeyPath);
+ free(KeyPath);
return FALSE;
}
- heap_free(KeyPath);
+ free(KeyPath);
if (ERROR_SUCCESS != RegQueryInfoKeyW(hKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &lenNameMax, &lenValueMax, NULL, NULL))
return FALSE;
lenName = ++lenNameMax;
- valName = heap_xalloc(lenName * sizeof(WCHAR));
+ valName = malloc(lenName * sizeof(WCHAR));
adjust = 0;
@@ -267,8 +265,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
if (mode & SEARCH_VALUES) {
if (match_string(valName, sstring, mode)) {
- heap_free(valName);
- heap_free(buffer);
+ free(valName);
+ free(buffer);
RegCloseKey(hKey);
*row = i+adjust;
return TRUE;
@@ -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 (!buffer)
- buffer = heap_xalloc(lenValueMax);
+ buffer = malloc(lenValueMax);
lenName = lenNameMax;
lenValue = lenValueMax;
if (ERROR_SUCCESS != RegEnumValueW(hKey, i, valName, &lenName, NULL, &type, (LPBYTE)buffer, &lenValue))
break;
if (match_string(buffer, sstring, mode)) {
- heap_free(valName);
- heap_free(buffer);
+ free(valName);
+ free(buffer);
RegCloseKey(hKey);
*row = i+adjust;
return TRUE;
@@ -294,8 +292,8 @@ static BOOL match_item(HWND hwndTV, HTREEITEM hItem, LPCWSTR sstring, int mode,
i++;
}
- heap_free(valName);
- heap_free(buffer);
+ free(valName);
+ free(buffer);
RegCloseKey(hKey);
}
return FALSE;
@@ -371,7 +369,7 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
} else {
hKey = hRoot;
}
- heap_free(KeyPath);
+ free(KeyPath);
if (RegQueryInfoKeyW(hKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) {
return FALSE;
@@ -392,10 +390,10 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
}
dwMaxSubKeyLen++; /* account for the \0 terminator */
- Name = heap_xalloc(dwMaxSubKeyLen * sizeof(WCHAR));
+ Name = malloc(dwMaxSubKeyLen * sizeof(WCHAR));
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. */
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
@@ -422,8 +420,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
tvItem.mask = TVIF_TEXT;
tvItem.hItem = childItem;
if (!TreeView_GetItemW(hwndTV, &tvItem)) {
- heap_free(Name);
- heap_free(tvItem.pszText);
+ free(Name);
+ free(tvItem.pszText);
return FALSE;
}
@@ -438,8 +436,8 @@ static BOOL RefreshTreeItem(HWND hwndTV, HTREEITEM hItem)
AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
}
}
- heap_free(Name);
- heap_free(tvItem.pszText);
+ free(Name);
+ free(tvItem.pszText);
RegCloseKey(hKey);
/* 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)
errCode = RegQueryInfoKeyW(hNewKey, 0, 0, 0, &dwCount, &dwMaxSubKeyLen, 0, 0, 0, 0, 0, 0);
if (errCode != ERROR_SUCCESS) goto done;
dwMaxSubKeyLen++; /* account for the \0 terminator */
- Name = heap_xalloc(dwMaxSubKeyLen * sizeof(WCHAR));
+ Name = malloc(dwMaxSubKeyLen * sizeof(WCHAR));
for (dwIndex = 0; dwIndex < dwCount; dwIndex++) {
DWORD cName = dwMaxSubKeyLen, dwSubCount;
@@ -663,7 +661,7 @@ BOOL UpdateExpandingTree(HWND hwndTV, HTREEITEM hItem, int state)
AddEntryToTree(hwndTV, hItem, Name, NULL, dwSubCount);
}
RegCloseKey(hNewKey);
- heap_free(Name);
+ free(Name);
done:
item.mask = TVIF_STATE;
@@ -674,7 +672,7 @@ done:
SendMessageW(hwndTV, WM_SETREDRAW, TRUE, 0);
SetCursor(hcursorOld);
expanding = FALSE;
- heap_free(keyPath);
+ free(keyPath);
return TRUE;
}
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/397
More information about the wine-devel
mailing list