Split the tui_win_info destructor
authorTom Tromey <tom@tromey.com>
Sun, 16 Jun 2019 16:52:27 +0000 (10:52 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 25 Jun 2019 13:48:27 +0000 (07:48 -0600)
This patch adds destructors to tui_source_window and tui_data_window,
and splits ~tui_win_info as appropriate.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

* tui/tui-data.h (struct tui_source_window)
(struct tui_data_window): Declare destructors.
* tui/tui-data.c (~tui_source_window, ~tui_data_window): New
destructors.
(tui_win_info): Simplify.

gdb/ChangeLog
gdb/tui/tui-data.c
gdb/tui/tui-data.h

index 412c442603578f2c0a70a496f225470b3e82a3ca..434d7dda79d86be239f91d5e7a4a0ea56b652e96 100644 (file)
@@ -1,3 +1,11 @@
+2019-06-25  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-data.h (struct tui_source_window)
+       (struct tui_data_window): Declare destructors.
+       * tui/tui-data.c (~tui_source_window, ~tui_data_window): New
+       destructors.
+       (tui_win_info): Simplify.
+
 2019-06-25  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-winsource.c (tui_display_main)
index d9b8bd6aae39b585c1eaf732be27d847b1fe8b99..d24941c10dad43580392d7ff62230f5488a9c3e3 100644 (file)
@@ -617,47 +617,43 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
   return index_start;
 }
 
-tui_win_info::~tui_win_info ()
+tui_source_window::~tui_source_window ()
 {
-  struct tui_gen_win_info *generic_win;
+  if (detail.source_info.fullname)
+    {
+      xfree (detail.source_info.fullname);
+      detail.source_info.fullname = NULL;
+    }
+  struct tui_gen_win_info *generic_win = detail.source_info.execution_info;
+  if (generic_win != NULL)
+    {
+      tui_delete_win (generic_win->handle);
+      generic_win->handle = NULL;
+      tui_free_win_content (generic_win);
+    }
+}  
 
-  switch (generic.type)
+tui_data_window::~tui_data_window ()
+{
+  if (generic.content != NULL)
     {
-    case SRC_WIN:
-    case DISASSEM_WIN:
-      if (detail.source_info.fullname)
-        {
-          xfree (detail.source_info.fullname);
-          detail.source_info.fullname = NULL;
-        }
-      generic_win = detail.source_info.execution_info;
-      if (generic_win != NULL)
-       {
-         tui_delete_win (generic_win->handle);
-         generic_win->handle = NULL;
-         tui_free_win_content (generic_win);
-       }
-      break;
-    case DATA_WIN:
-      if (generic.content != NULL)
-       {
-         tui_free_data_content (detail.data_display_info.regs_content,
-                                detail.data_display_info.regs_content_count);
-         detail.data_display_info.regs_content = NULL;
-         detail.data_display_info.regs_content_count = 0;
-         tui_free_data_content (detail.data_display_info.data_content,
-                                detail.data_display_info.data_content_count);
-         detail.data_display_info.data_content = NULL;
-         detail.data_display_info.data_content_count = 0;
-         detail.data_display_info.regs_column_count = 1;
-         detail.data_display_info.display_regs = FALSE;
-         generic.content = NULL;
-         generic.content_size = 0;
-       }
-      break;
-    default:
-      break;
+      tui_free_data_content (detail.data_display_info.regs_content,
+                            detail.data_display_info.regs_content_count);
+      detail.data_display_info.regs_content = NULL;
+      detail.data_display_info.regs_content_count = 0;
+      tui_free_data_content (detail.data_display_info.data_content,
+                            detail.data_display_info.data_content_count);
+      detail.data_display_info.data_content = NULL;
+      detail.data_display_info.data_content_count = 0;
+      detail.data_display_info.regs_column_count = 1;
+      detail.data_display_info.display_regs = FALSE;
+      generic.content = NULL;
+      generic.content_size = 0;
     }
+}  
+
+tui_win_info::~tui_win_info ()
+{
   if (generic.handle != NULL)
     {
       tui_delete_win (generic.handle);
index 8008893854368c39e3210dc48793360e261ae071..7adeb5687c91e69775def9bbf187aed07f001edf 100644 (file)
@@ -294,6 +294,7 @@ public:
 struct tui_source_window : public tui_win_info
 {
   explicit tui_source_window (enum tui_win_type type);
+  ~tui_source_window () override;
   DISABLE_COPY_AND_ASSIGN (tui_source_window);
 
   void clear_detail () override;
@@ -302,6 +303,7 @@ struct tui_source_window : public tui_win_info
 struct tui_data_window : public tui_win_info
 {
   tui_data_window ();
+  ~tui_data_window () override;
   DISABLE_COPY_AND_ASSIGN (tui_data_window);
 
   void clear_detail () override;