From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85370 invoked by alias); 4 Apr 2018 04:40:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 85253 invoked by uid 89); 4 Apr 2018 04:40:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Apr 2018 04:40:53 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway31.websitewelcome.com (Postfix) with ESMTP id A195DAF2556 for ; Tue, 3 Apr 2018 23:40:52 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 3aE8fj0AvQUwq3aE8fXf8L; Tue, 03 Apr 2018 23:40:52 -0500 Received: from 75-166-37-45.hlrn.qwest.net ([75.166.37.45]:43166 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1f3aE8-000hxu-CF; Tue, 03 Apr 2018 23:40:52 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 05/10] Have filter_results take a std::vector Date: Wed, 04 Apr 2018 04:41:00 -0000 Message-Id: <20180404044049.31481-6-tom@tromey.com> In-Reply-To: <20180404044049.31481-1-tom@tromey.com> References: <20180404044049.31481-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1f3aE8-000hxu-CF X-Source-Sender: 75-166-37-45.hlrn.qwest.net (bapiya.Home) [75.166.37.45]:43166 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2018-04/txt/msg00059.txt.bz2 This chagnes filter_results to take a std::vector, allowing the removal of some cleanups in its callers. gdb/ChangeLog 2018-04-03 Tom Tromey * 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 c445a0be57..91dabb6117 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 *result, - VEC (const_char_ptr) *filters) + const std::vector &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; @@ -1497,16 +1494,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 filters; std::vector 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) { @@ -1553,7 +1547,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; } @@ -1587,7 +1580,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; } @@ -1601,7 +1593,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 @@ -1613,7 +1605,6 @@ decode_line_2 (struct linespec_state *self, } filter_results (self, result, filters); - do_cleanups (old_chain); } @@ -3225,7 +3216,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 filters; linespec_parser parser; struct linespec_state *state; @@ -3277,8 +3268,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