fixed 4 memory leaks
Modified: trunk/reactos/subsys/system/regedit/childwnd.c
Modified: trunk/reactos/subsys/system/regedit/listview.c
Modified: trunk/reactos/subsys/system/regedit/main.c
Modified: trunk/reactos/subsys/system/regedit/main.h
Modified: trunk/reactos/subsys/system/regedit/treeview.c

Modified: trunk/reactos/subsys/system/regedit/childwnd.c
--- trunk/reactos/subsys/system/regedit/childwnd.c	2005-10-28 00:03:01 UTC (rev 18818)
+++ trunk/reactos/subsys/system/regedit/childwnd.c	2005-10-28 00:14:27 UTC (rev 18819)
@@ -310,6 +310,9 @@
         }
         goto def;
     case WM_DESTROY:
+		DestroyTreeView();
+		DestroyListView(pChildWnd->hListWnd);
+		DestroyMainMenu();
         HeapFree(GetProcessHeap(), 0, pChildWnd);
         pChildWnd = NULL;
         PostQuitMessage(0);

Modified: trunk/reactos/subsys/system/regedit/listview.c
--- trunk/reactos/subsys/system/regedit/listview.c	2005-10-28 00:03:01 UTC (rev 18818)
+++ trunk/reactos/subsys/system/regedit/listview.c	2005-10-28 00:14:27 UTC (rev 18819)
@@ -494,6 +494,24 @@
     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;

Modified: trunk/reactos/subsys/system/regedit/main.c
--- trunk/reactos/subsys/system/regedit/main.c	2005-10-28 00:03:01 UTC (rev 18818)
+++ trunk/reactos/subsys/system/regedit/main.c	2005-10-28 00:14:27 UTC (rev 18819)
@@ -181,10 +181,19 @@
 
 /******************************************************************************/
 
+/* 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();
 }

Modified: trunk/reactos/subsys/system/regedit/main.h
--- trunk/reactos/subsys/system/regedit/main.h	2005-10-28 00:03:01 UTC (rev 18818)
+++ trunk/reactos/subsys/system/regedit/main.h	2005-10-28 00:14:27 UTC (rev 18819)
@@ -107,6 +107,9 @@
 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);

Modified: trunk/reactos/subsys/system/regedit/treeview.c
--- trunk/reactos/subsys/system/regedit/treeview.c	2005-10-28 00:03:01 UTC (rev 18818)
+++ trunk/reactos/subsys/system/regedit/treeview.c	2005-10-28 00:14:27 UTC (rev 18819)
@@ -101,7 +101,9 @@
     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 @@
     return hwndTV;
 }
 
+void DestroyTreeView() {
+	if (pathBuffer)
+		HeapFree(GetProcessHeap(), 0, pathBuffer);
+}
+
 BOOL SelectNode(HWND hwndTV, LPCTSTR keyPath)
 {
 	HTREEITEM hRoot, hItem;