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: [RFA 05/10] Have filter_results take a std::vector
Date: Sun, 01 Apr 2018 16:35:00 -0000	[thread overview]
Message-ID: <20180401163539.15314-6-tom@tromey.com> (raw)
In-Reply-To: <20180401163539.15314-1-tom@tromey.com>

This chagnes filter_results to take a std::vector, allowing the
removal of some cleanups in its callers.

2018-03-31  Tom Tromey  <tom@tromey.com>

	* linespec.c (filter_results): Use std::vector.
	(decode_line_2, decode_line_full): Update.
---
 gdb/ChangeLog  |  5 +++++
 gdb/linespec.c | 22 ++++++----------------
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index 02466759c0..ca916a2a1d 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1402,12 +1402,9 @@ canonical_to_fullform (const struct linespec_canonical_name *canonical)
 static void
 filter_results (struct linespec_state *self,
 		std::vector<symtab_and_line> *result,
-		VEC (const_char_ptr) *filters)
+		const std::vector<const char *> &filters)
 {
-  int i;
-  const char *name;
-
-  for (i = 0; VEC_iterate (const_char_ptr, filters, i, name); ++i)
+  for (const char *name : filters)
     {
       linespec_sals lsal;
 
@@ -1501,16 +1498,13 @@ decode_line_2 (struct linespec_state *self,
   char *args;
   const char *prompt;
   int i;
-  struct cleanup *old_chain;
-  VEC (const_char_ptr) *filters = NULL;
+  std::vector<const char *> filters;
   std::vector<struct decode_line_2_item> items;
 
   gdb_assert (select_mode != multiple_symbols_all);
   gdb_assert (self->canonical != NULL);
   gdb_assert (!result->empty ());
 
-  old_chain = make_cleanup (VEC_cleanup (const_char_ptr), &filters);
-
   /* Prepare ITEMS array.  */
   for (i = 0; i < result->size (); ++i)
     {
@@ -1557,7 +1551,6 @@ decode_line_2 (struct linespec_state *self,
   
   if (select_mode == multiple_symbols_all || items.size () == 1)
     {
-      do_cleanups (old_chain);
       convert_results_to_lsals (self, result);
       return;
     }
@@ -1591,7 +1584,6 @@ decode_line_2 (struct linespec_state *self,
 	     multiple_symbols_all behavior even with the 'ask'
 	     setting; and he can get separate breakpoints by entering
 	     "2-57" at the query.  */
-	  do_cleanups (old_chain);
 	  convert_results_to_lsals (self, result);
 	  return;
 	}
@@ -1605,7 +1597,7 @@ decode_line_2 (struct linespec_state *self,
 
 	  if (!item->selected)
 	    {
-	      VEC_safe_push (const_char_ptr, filters, item->fullform.c_str ());
+	      filters.push_back (item->fullform.c_str ());
 	      item->selected = 1;
 	    }
 	  else
@@ -1617,7 +1609,6 @@ decode_line_2 (struct linespec_state *self,
     }
 
   filter_results (self, result, filters);
-  do_cleanups (old_chain);
 }
 
 \f
@@ -3228,7 +3219,7 @@ decode_line_full (const struct event_location *location, int flags,
 		  const char *filter)
 {
   struct cleanup *cleanups;
-  VEC (const_char_ptr) *filters = NULL;
+  std::vector<const char *> filters;
   linespec_parser parser;
   struct linespec_state *state;
 
@@ -3280,8 +3271,7 @@ decode_line_full (const struct event_location *location, int flags,
     {
       if (filter != NULL)
 	{
-	  make_cleanup (VEC_cleanup (const_char_ptr), &filters);
-	  VEC_safe_push (const_char_ptr, filters, filter);
+	  filters.push_back (filter);
 	  filter_results (state, &result, filters);
 	}
       else
-- 
2.13.6

  parent reply	other threads:[~2018-04-01 16:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01 16:35 [RFA 00/10] Remove some cleanups from linespec.c Tom Tromey
2018-04-01 16:35 ` [RFA 02/10] Fix some indentation in linespec.c Tom Tromey
2018-04-02  1:49   ` Simon Marchi
2018-04-01 16:35 ` [RFA 06/10] Remove a string copy from event_location_to_sals Tom Tromey
2018-04-01 16:35 ` [RFA 09/10] Remove typep and VEC(typep) from linespec.c Tom Tromey
2018-04-01 16:35 ` [RFA 01/10] Remove some cleanups from search_minsyms_for_name Tom Tromey
2018-04-02  1:39   ` Simon Marchi
2018-04-01 16:35 ` Tom Tromey [this message]
2018-04-01 16:35 ` [RFA 04/10] Return std::string from canonical_to_fullform Tom Tromey
2018-04-02  2:15   ` Simon Marchi
2018-04-01 16:35 ` [RFA 08/10] More use of std::vector in linespec.c Tom Tromey
2018-04-02  2:35   ` Simon Marchi
2018-04-01 16:35 ` [RFA 10/10] Remove unnecessary include from linespec.h Tom Tromey
2018-04-01 16:35 ` [RFA 03/10] Make copy_token_string return unique_xmalloc_ptr Tom Tromey
2018-04-01 16:35 ` [RFA 07/10] Change streq to return bool Tom Tromey
2018-04-02  2:28   ` Simon Marchi
2018-04-02  2:44 ` [RFA 00/10] Remove some cleanups from linespec.c Simon Marchi
2018-04-03 22:31   ` 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=20180401163539.15314-6-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).