public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 06/11] Change varobj_dynamic::saved_item to unique_ptr
Date: Sat, 24 Oct 2020 15:08:51 -0600	[thread overview]
Message-ID: <20201024210856.12021-7-tom@tromey.com> (raw)
In-Reply-To: <20201024210856.12021-1-tom@tromey.com>

This changes varobj_dynamic::saved_item to be a unique_ptr.

gdb/ChangeLog
2020-10-24  Tom Tromey  <tom@tromey.com>

	* varobj.c (struct varobj_dynamic) <saved_item>: Now unique_ptr.
	(varobj_clear_saved_item, update_dynamic_varobj_children):
	Update.
---
 gdb/ChangeLog |  6 ++++++
 gdb/varobj.c  | 12 ++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/gdb/varobj.c b/gdb/varobj.c
index fcfc319008b..21e03eb397a 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -131,7 +131,7 @@ struct varobj_dynamic
      already reported.  However, we don't want to install this value
      when we read it, because that will mess up future updates.  So,
      we stash it here instead.  */
-  varobj_item *saved_item = NULL;
+  std::unique_ptr<varobj_item> saved_item;
 };
 
 /* Private function prototypes */
@@ -680,8 +680,7 @@ varobj_clear_saved_item (struct varobj_dynamic *var)
   if (var->saved_item != NULL)
     {
       value_decref (var->saved_item->value);
-      delete var->saved_item;
-      var->saved_item = NULL;
+      var->saved_item.reset (nullptr);
     }
 }
 
@@ -723,10 +722,7 @@ update_dynamic_varobj_children (struct varobj *var,
 
       /* See if there was a leftover from last time.  */
       if (var->dynamic->saved_item != NULL)
-	{
-	  item = std::unique_ptr<varobj_item> (var->dynamic->saved_item);
-	  var->dynamic->saved_item = NULL;
-	}
+	item = std::move (var->dynamic->saved_item);
       else
 	{
 	  item = var->dynamic->child_iter->next ();
@@ -757,7 +753,7 @@ update_dynamic_varobj_children (struct varobj *var,
 	}
       else
 	{
-	  var->dynamic->saved_item = item.release ();
+	  var->dynamic->saved_item = std::move (item);
 
 	  /* We want to truncate the child list just before this
 	     element.  */
-- 
2.17.2


  parent reply	other threads:[~2020-10-24 21:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-24 21:08 [PATCH 00/11] Some varobj C++-ification and cleanup Tom Tromey
2020-10-24 21:08 ` [PATCH 01/11] Use htab_t in varobj Tom Tromey
2020-10-24 21:08 ` [PATCH 02/11] Change varobj.c:rootlist to a std::list Tom Tromey
2020-10-24 21:08 ` [PATCH 03/11] Change all_root_varobjs to take a function_view Tom Tromey
2020-10-24 21:08 ` [PATCH 04/11] C++-ify varobj iteration Tom Tromey
2020-10-24 21:08 ` [PATCH 05/11] Change varobj_iter::next to return unique_ptr Tom Tromey
2020-10-24 21:08 ` Tom Tromey [this message]
2020-10-24 21:08 ` [PATCH 07/11] Change varobj_dynamic::child_iter to unique_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 08/11] Change varobj_item::value to a value_ref_ptr Tom Tromey
2020-10-24 21:08 ` [PATCH 09/11] Remove varobj_clear_saved_item Tom Tromey
2020-10-24 21:08 ` [PATCH 10/11] Use gdbpy_ref in instantiate_pretty_printer Tom Tromey
2020-10-24 21:08 ` [PATCH 11/11] install_variable cannot fail Tom Tromey
2020-12-11 16:46 ` [PATCH 00/11] Some varobj C++-ification and cleanup Tom Tromey

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=20201024210856.12021-7-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@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).