Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 3/5] Use new and delete for struct infcall_control_state
Date: Wed, 11 Jul 2018 14:16:00 -0000	[thread overview]
Message-ID: <20180711141552.10136-4-tom@tromey.com> (raw)
In-Reply-To: <20180711141552.10136-1-tom@tromey.com>

This changes infrun.c to use new and delete for infcall_control_state.

gdb/ChangeLog
2018-07-11  Tom Tromey  <tom@tromey.com>

	* infrun.c (struct infcall_control_state): Add initializers.
	(save_infcall_control_state): Use new.
	(restore_infcall_control_state, discard_infcall_control_state):
	Use delete.
---
 gdb/ChangeLog |  7 +++++++
 gdb/infrun.c  | 17 ++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d46ccf53999..95d4f51f62c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2018-07-11  Tom Tromey  <tom@tromey.com>
+
+	* infrun.c (struct infcall_control_state): Add initializers.
+	(save_infcall_control_state): Use new.
+	(restore_infcall_control_state, discard_infcall_control_state):
+	Use delete.
+
 2018-07-11  Tom Tromey  <tom@tromey.com>
 
 	* infrun.c (struct infcall_suspend_state) <registers>: Now a
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 1157b266b1a..3bc8dc03830 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8927,15 +8927,15 @@ get_infcall_suspend_state_regcache (struct infcall_suspend_state *inf_state)
 
 struct infcall_control_state
 {
-  struct thread_control_state thread_control;
-  struct inferior_control_state inferior_control;
+  struct thread_control_state thread_control {};
+  struct inferior_control_state inferior_control {};
 
   /* Other fields:  */
-  enum stop_stack_kind stop_stack_dummy;
-  int stopped_by_random_signal;
+  enum stop_stack_kind stop_stack_dummy = STOP_NONE;
+  int stopped_by_random_signal = 0;
 
   /* ID if the selected frame when the inferior function call was made.  */
-  struct frame_id selected_frame_id;
+  struct frame_id selected_frame_id {};
 };
 
 /* Save all of the information associated with the inferior<==>gdb
@@ -8944,8 +8944,7 @@ struct infcall_control_state
 struct infcall_control_state *
 save_infcall_control_state (void)
 {
-  struct infcall_control_state *inf_status =
-    XNEW (struct infcall_control_state);
+  struct infcall_control_state *inf_status = new struct infcall_control_state;
   struct thread_info *tp = inferior_thread ();
   struct inferior *inf = current_inferior ();
 
@@ -9031,7 +9030,7 @@ restore_infcall_control_state (struct infcall_control_state *inf_status)
       END_CATCH
     }
 
-  xfree (inf_status);
+  delete inf_status;
 }
 
 static void
@@ -9061,7 +9060,7 @@ discard_infcall_control_state (struct infcall_control_state *inf_status)
   /* See save_infcall_control_state for info on stop_bpstat.  */
   bpstat_clear (&inf_status->thread_control.stop_bpstat);
 
-  xfree (inf_status);
+  delete inf_status;
 }
 \f
 /* See infrun.h.  */
-- 
2.17.1


  parent reply	other threads:[~2018-07-11 14:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-11 14:16 [RFA 0/5] remove some infrun-related cleanups Tom Tromey
2018-07-11 14:15 ` [RFA 1/5] Use new and delete for struct infcall_suspend_state Tom Tromey
2018-07-11 15:33   ` Simon Marchi
2018-07-11 14:15 ` [RFA 4/5] Remove two infrun cleanups Tom Tromey
2018-07-11 14:16 ` [RFA 2/5] Remove cleanup from infrun.c Tom Tromey
2018-07-11 14:16 ` Tom Tromey [this message]
2018-07-11 15:36   ` [RFA 3/5] Use new and delete for struct infcall_control_state Simon Marchi
2018-07-11 15:42     ` Simon Marchi
2018-07-11 14:16 ` [RFA 5/5] Remove release_stop_context_cleanup Tom Tromey
2018-07-11 14:54 ` [RFA 0/5] remove some infrun-related cleanups Pedro Alves
2018-07-11 15:16   ` Simon Marchi
2018-07-11 19:29     ` 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=20180711141552.10136-4-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