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 v2 14/17] Use std::vector in compile-loc2c.c
Date: Tue, 11 Apr 2017 15:22:00 -0000	[thread overview]
Message-ID: <20170411150112.23207-15-tom@tromey.com> (raw)
In-Reply-To: <20170411150112.23207-1-tom@tromey.com>

This changes compile-loc2c.c to use std::vector in place of a VEC,
allowing the removal of a cleanup.

gdb/ChangeLog
2017-04-11  Tom Tromey  <tom@tromey.com>

	* compile/compile-loc2c.c (compute_stack_depth_worker): Change
	type of "to_do".  Update.
	(compute_stack_depth): Use std::vector.
---
 gdb/ChangeLog               |  6 ++++++
 gdb/compile/compile-loc2c.c | 20 +++++++++-----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f9e4a83..346ee66 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2017-04-11  Tom Tromey  <tom@tromey.com>
 
+	* compile/compile-loc2c.c (compute_stack_depth_worker): Change
+	type of "to_do".  Update.
+	(compute_stack_depth): Use std::vector.
+
+2017-04-11  Tom Tromey  <tom@tromey.com>
+
 	* printcmd.c (find_instruction_backward): Use std::vector.
 
 2017-04-11  Tom Tromey  <tom@tromey.com>
diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c
index f1296e8..a53214f 100644
--- a/gdb/compile/compile-loc2c.c
+++ b/gdb/compile/compile-loc2c.c
@@ -72,7 +72,7 @@ struct insn_info
 static void
 compute_stack_depth_worker (int start, int *need_tempvar,
 			    struct insn_info *info,
-			    VEC (int) **to_do,
+			    std::vector<int> *to_do,
 			    enum bfd_endian byte_order, unsigned int addr_size,
 			    const gdb_byte *op_ptr, const gdb_byte *op_end)
 {
@@ -334,7 +334,7 @@ compute_stack_depth_worker (int start, int *need_tempvar,
 	  /* If the destination has not been seen yet, add it to the
 	     to-do list.  */
 	  if (!info[offset].visited)
-	    VEC_safe_push (int, *to_do, offset);
+	    to_do->push_back (offset);
 	  SET_CHECK_DEPTH (offset);
 	  info[offset].label = 1;
 	  /* We're done with this line of code.  */
@@ -348,7 +348,7 @@ compute_stack_depth_worker (int start, int *need_tempvar,
 	  /* If the destination has not been seen yet, add it to the
 	     to-do list.  */
 	  if (!info[offset].visited)
-	    VEC_safe_push (int, *to_do, offset);
+	    to_do->push_back (offset);
 	  SET_CHECK_DEPTH (offset);
 	  info[offset].label = 1;
 	  break;
@@ -390,22 +390,21 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size,
 		     struct insn_info **info)
 {
   unsigned char *set;
-  struct cleanup *outer_cleanup, *cleanup;
-  VEC (int) *to_do = NULL;
+  struct cleanup *outer_cleanup;
+  std::vector<int> to_do;
   int stack_depth, i;
 
   *info = XCNEWVEC (struct insn_info, op_end - op_ptr);
   outer_cleanup = make_cleanup (xfree, *info);
 
-  cleanup = make_cleanup (VEC_cleanup (int), &to_do);
-
-  VEC_safe_push (int, to_do, 0);
+  to_do.push_back (0);
   (*info)[0].depth = initial_depth;
   (*info)[0].visited = 1;
 
-  while (!VEC_empty (int, to_do))
+  while (!to_do.empty ())
     {
-      int ndx = VEC_pop (int, to_do);
+      int ndx = to_do.back ();
+      to_do.pop_back ();
 
       compute_stack_depth_worker (ndx, need_tempvar, *info, &to_do,
 				  byte_order, addr_size,
@@ -422,7 +421,6 @@ compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size,
 	*is_tls = 1;
     }
 
-  do_cleanups (cleanup);
   discard_cleanups (outer_cleanup);
   return stack_depth + 1;
 }
-- 
2.9.3


  parent reply	other threads:[~2017-04-11 15:22 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11 15:02 [RFA v2 00/17] miscellaneous C++-ification Tom Tromey
2017-04-11 15:01 ` [RFA v2 16/17] Add a constructor and destructor to linespec_result Tom Tromey
2017-04-12  2:25   ` Simon Marchi
2017-04-12 14:30     ` Tom Tromey
2017-04-11 15:01 ` [RFA v2 11/17] Use scoped_restore in more places Tom Tromey
2017-04-11 15:01 ` [RFA v2 09/17] Remove some cleanups from location.c Tom Tromey
2017-04-11 15:01 ` [RFA v2 01/17] Introduce event_location_up Tom Tromey
2017-04-11 15:01 ` [RFA v2 10/17] C++ify mi_parse Tom Tromey
2017-04-12 11:26   ` Pedro Alves
2017-04-12 16:15     ` Tom Tromey
2017-04-12 16:19       ` Pedro Alves
2017-04-12 18:05         ` Tom Tromey
2017-04-12 18:37           ` Pedro Alves
2017-04-12 19:25             ` Tom Tromey
2017-04-13  2:36               ` Pedro Alves
2017-04-13 13:44                 ` Tom Tromey
2017-04-11 15:01 ` [RFA v2 04/17] Introduce gdb_dlhandle_up Tom Tromey
2017-04-11 15:01 ` [RFA v2 17/17] Change linespec_result::location to be an event_location_up Tom Tromey
2017-04-12  2:39   ` Simon Marchi
2017-04-11 15:01 ` [RFA v2 12/17] Use std::vector in reread_symbols Tom Tromey
2017-04-11 15:01 ` [RFA v2 05/17] Change increment_reading_symtab to return a scoped_restore Tom Tromey
2017-04-12 11:16   ` Pedro Alves
2017-04-12 14:31     ` Tom Tromey
2017-04-11 15:01 ` [RFA v2 02/17] Introduce command_line_up Tom Tromey
2017-04-11 15:02 ` [RFA v2 08/17] Remove some cleanups from gnu-v3-abi.c Tom Tromey
2017-04-11 15:02 ` [RFA v2 13/17] Use std::vector in find_instruction_backward Tom Tromey
2017-04-11 15:02 ` [RFA v2 07/17] Fix up wchar_iterator comment Tom Tromey
2017-04-11 15:21 ` [RFA v2 06/17] Remove cleanup_iconv Tom Tromey
2017-04-12 11:19   ` Pedro Alves
2017-04-12 15:05     ` Tom Tromey
2017-04-11 15:21 ` [RFA v2 03/17] Change find_pcs_for_symtab_line to return a std::vector Tom Tromey
2017-04-11 15:22 ` Tom Tromey [this message]
2017-04-11 15:23 ` [RFA v2 15/17] Change breakpoint event locations to event_location_up Tom Tromey
2017-04-12  2:25   ` Simon Marchi
2017-04-12  2:49 ` [RFA v2 00/17] miscellaneous C++-ification Simon Marchi
2017-04-12 11:38   ` Pedro Alves

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=20170411150112.23207-15-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