mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
fixed 4 memory leaks
svn path=/trunk/; revision=18819
This commit is contained in:
parent
14db8e6026
commit
d0cb6cb732
5 changed files with 42 additions and 2 deletions
|
@ -310,6 +310,9 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
}
|
||||
goto def;
|
||||
case WM_DESTROY:
|
||||
DestroyTreeView();
|
||||
DestroyListView(pChildWnd->hListWnd);
|
||||
DestroyMainMenu();
|
||||
HeapFree(GetProcessHeap(), 0, pChildWnd);
|
||||
pChildWnd = NULL;
|
||||
PostQuitMessage(0);
|
||||
|
|
|
@ -494,6 +494,24 @@ fail:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void DestroyListView(HWND hwndLV) {
|
||||
INT count, i;
|
||||
LVITEM item;
|
||||
|
||||
if (g_valueName)
|
||||
HeapFree(GetProcessHeap(), 0, g_valueName);
|
||||
|
||||
count = ListView_GetItemCount(hwndLV);
|
||||
for (i = 0; i < count; i++) {
|
||||
item.mask = LVIF_PARAM;
|
||||
item.iItem = i;
|
||||
ListView_GetItem(hwndLV, &item);
|
||||
free(((LINE_INFO*)item.lParam)->name);
|
||||
HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCTSTR keyPath)
|
||||
{
|
||||
DWORD max_sub_key_len;
|
||||
|
|
|
@ -181,10 +181,19 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
/* we need to destroy the main menu before destroying the main window
|
||||
to avoid a memory leak */
|
||||
|
||||
void DestroyMainMenu() {
|
||||
DestroyMenu(hMenuFrame);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
void ExitInstance(HINSTANCE hInstance)
|
||||
{
|
||||
UnregisterHexEditorClass(hInstance);
|
||||
DestroyMenu(hMenuFrame);
|
||||
|
||||
DestroyMenu(hPopupMenus);
|
||||
UnloadAclUiDll();
|
||||
}
|
||||
|
|
|
@ -107,6 +107,9 @@ extern HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPTSTR name);
|
|||
extern HWND StartKeyRename(HWND hwndTV);
|
||||
extern BOOL CreateNewKey(HWND hwndTV, HTREEITEM hItem);
|
||||
extern BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath);
|
||||
extern void DestroyTreeView( void );
|
||||
extern void DestroyListView( HWND hwndLV );
|
||||
extern void DestroyMainMenu( void );
|
||||
|
||||
/* edit.c */
|
||||
extern BOOL ModifyValue(HWND hwnd, HKEY hKey, LPCTSTR valueName, BOOL EditBin);
|
||||
|
|
|
@ -101,7 +101,9 @@ LPCTSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY* phRootKey)
|
|||
if (maxLen == -1) return NULL;
|
||||
if (!hItem) hItem = TreeView_GetSelection(hwndTV);
|
||||
if (!hItem) return NULL;
|
||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) return NULL;
|
||||
if (!get_item_path(hwndTV, hItem, phRootKey, &pathBuffer, &pathLen, &maxLen)) {
|
||||
return NULL;
|
||||
}
|
||||
return pathBuffer;
|
||||
}
|
||||
|
||||
|
@ -561,6 +563,11 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id)
|
|||
return hwndTV;
|
||||
}
|
||||
|
||||
void DestroyTreeView() {
|
||||
if (pathBuffer)
|
||||
HeapFree(GetProcessHeap(), 0, pathBuffer);
|
||||
}
|
||||
|
||||
BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
|
||||
{
|
||||
HTREEITEM hRoot, hItem;
|
||||
|
|
Loading…
Reference in a new issue