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

regedit: Use the heap_*() functions in listview.c where possible.

parent 1744277b
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <stdio.h> #include <stdio.h>
#include "main.h" #include "main.h"
#include "regproc.h"
#include "wine/unicode.h" #include "wine/unicode.h"
static INT Image_String; static INT Image_String;
...@@ -48,21 +49,18 @@ static int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCF ...@@ -48,21 +49,18 @@ static int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCF
LPWSTR GetItemText(HWND hwndLV, UINT item) LPWSTR GetItemText(HWND hwndLV, UINT item)
{ {
LPWSTR newStr, curStr; WCHAR *curStr;
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 = HeapAlloc(GetProcessHeap(), 0, maxLen * sizeof(WCHAR)); curStr = heap_xalloc(maxLen * sizeof(WCHAR));
if (!curStr) return NULL;
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;
newStr = HeapReAlloc(GetProcessHeap(), 0, curStr, maxLen * sizeof(WCHAR)); curStr = heap_xrealloc(curStr, maxLen * sizeof(WCHAR));
if (!newStr) break;
curStr = newStr;
} while (TRUE); } while (TRUE);
HeapFree(GetProcessHeap(), 0, curStr); heap_free(curStr);
return NULL; return NULL;
} }
...@@ -71,7 +69,7 @@ LPCWSTR GetValueName(HWND hwndLV) ...@@ -71,7 +69,7 @@ LPCWSTR GetValueName(HWND hwndLV)
INT item; INT item;
if (g_valueName != LPSTR_TEXTCALLBACKW) if (g_valueName != LPSTR_TEXTCALLBACKW)
HeapFree(GetProcessHeap(), 0, g_valueName); heap_free(g_valueName);
g_valueName = NULL; g_valueName = NULL;
item = SendMessageW(hwndLV, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED, 0)); item = SendMessageW(hwndLV, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED, 0));
...@@ -84,10 +82,9 @@ LPCWSTR GetValueName(HWND hwndLV) ...@@ -84,10 +82,9 @@ LPCWSTR GetValueName(HWND hwndLV)
BOOL update_listview_path(const WCHAR *path) BOOL update_listview_path(const WCHAR *path)
{ {
HeapFree(GetProcessHeap(), 0, g_currentPath); heap_free(g_currentPath);
g_currentPath = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(path) + 1) * sizeof(WCHAR)); g_currentPath = heap_xalloc((lstrlenW(path) + 1) * sizeof(WCHAR));
if (!g_currentPath) return FALSE;
lstrcpyW(g_currentPath, path); lstrcpyW(g_currentPath, path);
return TRUE; return TRUE;
...@@ -141,13 +138,13 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz ...@@ -141,13 +138,13 @@ 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 = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR) * 3 + sizeof(WCHAR)); WCHAR *strBinary = heap_xalloc(size * sizeof(WCHAR) * 3 + sizeof(WCHAR));
WCHAR format[] = {'%','0','2','X',' ',0}; WCHAR format[] = {'%','0','2','X',' ',0};
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
wsprintfW( strBinary + i*3, format, pData[i] ); wsprintfW( strBinary + i*3, format, pData[i] );
strBinary[size * 3] = 0; strBinary[size * 3] = 0;
ListView_SetItemTextW(hwndLV, index, 2, strBinary); ListView_SetItemTextW(hwndLV, index, 2, strBinary);
HeapFree(GetProcessHeap(), 0, strBinary); heap_free(strBinary);
break; break;
} }
} }
...@@ -166,7 +163,7 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR ...@@ -166,7 +163,7 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR
if (Name) if (Name)
{ {
linfo->name = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(Name) + 1) * sizeof(WCHAR)); linfo->name = heap_xalloc((lstrlenW(Name) + 1) * sizeof(WCHAR));
lstrcpyW(linfo->name, Name); lstrcpyW(linfo->name, Name);
} else } else
{ {
...@@ -412,12 +409,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli ...@@ -412,12 +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 = HeapAlloc(GetProcessHeap(), 0, max_val_name_len * sizeof(WCHAR)); valName = heap_xalloc(max_val_name_len * sizeof(WCHAR));
if (!valName) valBuf = heap_xalloc(max_val_size);
goto done;
valBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size);
if (!valBuf)
goto done;
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) {
...@@ -449,8 +442,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli ...@@ -449,8 +442,8 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
result = TRUE; result = TRUE;
done: done:
HeapFree(GetProcessHeap(), 0, valBuf); heap_free(valBuf);
HeapFree(GetProcessHeap(), 0, valName); heap_free(valName);
SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0); SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
if (hKey) RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
......
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