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 @@
#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;
......
......@@ -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;
}
......@@ -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:*/
......
......@@ -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;
......
......@@ -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);
......
......@@ -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"
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
}
......
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