public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Add destructor to tui_win_info
Date: Tue, 25 Jun 2019 13:57:00 -0000	[thread overview]
Message-ID: <20190625135714.111586.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e7e11af42dca6482302833c4106974176aa66052

commit e7e11af42dca6482302833c4106974176aa66052
Author: Tom Tromey <tom@tromey.com>
Date:   Sun Jun 16 09:43:21 2019 -0600

    Add destructor to tui_win_info
    
    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.

Diff:
---
 gdb/ChangeLog      |  9 +++++++++
 gdb/tui/tui-data.c | 52 +++++++++++++++++++++++++---------------------------
 gdb/tui/tui-data.h |  3 ++-
 gdb/tui/tui-win.c  |  2 +-
 4 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b4395c0..537c70b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
 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.
 	* tui/tui-data.c (tui_alloc_win_info): Use new.
 	(tui_free_window): Use delete.
diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 117bda3..1c96fc1 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -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);
 }
 
 
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 047ee35..c5c2c2b 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -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);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index a1329e5..a69e087 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -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;
 	    }
 	}


                 reply	other threads:[~2019-06-25 13:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190625135714.111586.qmail@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).