Add destructor to tui_win_info
authorTom Tromey <tom@tromey.com>
Sun, 16 Jun 2019 15:43:21 +0000 (09:43 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 25 Jun 2019 13:48:24 +0000 (07:48 -0600)
This changes tui_free_window into a destructor for tui_free_window and
then updates the users.

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

* tui/tui-win.c (tui_resize_all): Use delete.
* tui/tui-data.h (struct tui_win_info) <~tui_win_info>: Declare
destructor.
(tui_free_window): Don't declare.
* tui/tui-data.c (~tui_win_info): Rename from tui_free_window.
Update.

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

index b4395c013847c9f567309227ec66e002f17100bb..537c70bebd0c60bd8249c21600429cae712e1545 100644 (file)
@@ -1,3 +1,12 @@
+2019-06-25  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-win.c (tui_resize_all): Use delete.
+       * tui/tui-data.h (struct tui_win_info) <~tui_win_info>: Declare
+       destructor.
+       (tui_free_window): Don't declare.
+       * tui/tui-data.c (~tui_win_info): Rename from tui_free_window.
+       Update.
+
 2019-06-25  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-data.h (struct tui_win_info): Add constructor.
index 117bda3c2004fa2298b61c56e953963a92b5420e..1c96fc1c077cfdce002234e5c19adbf4072fe578 100644 (file)
@@ -603,21 +603,20 @@ tui_add_content_elements (struct tui_gen_win_info *win_info,
   return index_start;
 }
 
-void
-tui_free_window (struct tui_win_info *win_info)
+tui_win_info::~tui_win_info ()
 {
   struct tui_gen_win_info *generic_win;
 
-  switch (win_info->generic.type)
+  switch (generic.type)
     {
     case SRC_WIN:
     case DISASSEM_WIN:
-      if (win_info->detail.source_info.fullname)
+      if (detail.source_info.fullname)
         {
-          xfree (win_info->detail.source_info.fullname);
-          win_info->detail.source_info.fullname = NULL;
+          xfree (detail.source_info.fullname);
+          detail.source_info.fullname = NULL;
         }
-      generic_win = win_info->detail.source_info.execution_info;
+      generic_win = detail.source_info.execution_info;
       if (generic_win != NULL)
        {
          tui_delete_win (generic_win->handle);
@@ -626,34 +625,33 @@ tui_free_window (struct tui_win_info *win_info)
        }
       break;
     case DATA_WIN:
-      if (win_info->generic.content != NULL)
+      if (generic.content != NULL)
        {
-         tui_free_data_content (win_info->detail.data_display_info.regs_content,
-                                win_info->detail.data_display_info.regs_content_count);
-         win_info->detail.data_display_info.regs_content = NULL;
-         win_info->detail.data_display_info.regs_content_count = 0;
-         tui_free_data_content (win_info->detail.data_display_info.data_content,
-                                win_info->detail.data_display_info.data_content_count);
-         win_info->detail.data_display_info.data_content = NULL;
-         win_info->detail.data_display_info.data_content_count = 0;
-         win_info->detail.data_display_info.regs_column_count = 1;
-         win_info->detail.data_display_info.display_regs = FALSE;
-         win_info->generic.content = NULL;
-         win_info->generic.content_size = 0;
+         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;
     }
-  if (win_info->generic.handle != NULL)
+  if (generic.handle != NULL)
     {
-      tui_delete_win (win_info->generic.handle);
-      win_info->generic.handle = NULL;
-      tui_free_win_content (&win_info->generic);
+      tui_delete_win (generic.handle);
+      generic.handle = NULL;
+      tui_free_win_content (&generic);
     }
-  if (win_info->generic.title)
-    xfree (win_info->generic.title);
-  delete win_info;
+  if (generic.title)
+    xfree (generic.title);
 }
 
 
index 047ee35d9848e03777b9a1ecd7b41c2794952cfc..c5c2c2b278df951a7e2502b79472403f69a5547a 100644 (file)
@@ -276,6 +276,8 @@ struct tui_win_info
     generic.type = type;
   }
 
+  ~tui_win_info ();
+
   DISABLE_COPY_AND_ASSIGN (tui_win_info);
 
   struct tui_gen_win_info generic;     /* General window information.  */
@@ -313,7 +315,6 @@ extern void tui_init_generic_part (struct tui_gen_win_info *);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
 extern int tui_add_content_elements (struct tui_gen_win_info *, 
                                     int);
-extern void tui_free_window (struct tui_win_info *);
 extern void tui_free_win_content (struct tui_gen_win_info *);
 extern void tui_free_data_content (tui_win_content, int);
 extern void tui_free_all_source_wins_content (void);
index a1329e54a81e9a80592b2f996c09488a61548842..a69e0878effed9ddbb02d392efca2c9e8c34766b 100644 (file)
@@ -785,7 +785,7 @@ tui_resize_all (void)
              && (tui_win_list[win_type] != NULL)
              && !tui_win_list[win_type]->generic.is_visible)
            {
-             tui_free_window (tui_win_list[win_type]);
+             delete tui_win_list[win_type];
              tui_win_list[win_type] = NULL;
            }
        }