From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18534 invoked by alias); 8 Apr 2017 20:12:23 -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 18407 invoked by uid 89); 8 Apr 2017 20:12:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=3487, 4216 X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Sat, 08 Apr 2017 20:12:19 +0000 Received: (qmail 2803 invoked by uid 0); 8 Apr 2017 20:12:19 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy6.mail.unifiedlayer.com with SMTP; 8 Apr 2017 20:12:19 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id 5wCG1v00Y2f2jeq01wCKeL; Sat, 08 Apr 2017 14:12:19 -0600 X-Authority-Analysis: v=2.2 cv=VKStp5HX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=AzvcPWV-tVgA:10 a=zstS-IiYAAAA:8 a=tRilUYlMihdCP0oBKXIA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-65-226.hlrn.qwest.net ([75.166.65.226]:43578 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1cwwiW-0003Fw-Hk; Sat, 08 Apr 2017 14:12:16 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 14/14] Use std::vector in compile-loc2c.c Date: Sat, 08 Apr 2017 20:12:00 -0000 Message-Id: <20170408201208.2672-15-tom@tromey.com> In-Reply-To: <20170408201208.2672-1-tom@tromey.com> References: <20170408201208.2672-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1cwwiW-0003Fw-Hk X-Source-Sender: 75-166-65-226.hlrn.qwest.net (bapiya.Home) [75.166.65.226]:43578 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-SW-Source: 2017-04/txt/msg00202.txt.bz2 This changes compile-loc2c.c to use std::vector in place of a VEC, allowing the removal of a cleanup. 2017-04-07 Tom Tromey * 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 e46f99d..0cfb3e5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2017-04-07 Tom Tromey + * compile/compile-loc2c.c (compute_stack_depth_worker): Change + type of "to_do". Update. + (compute_stack_depth): Use std::vector. + +2017-04-07 Tom Tromey + * printcmd.c (find_instruction_backward): Use std::vector. 2017-04-07 Tom Tromey 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 *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 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