From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55678 invoked by alias); 17 Feb 2018 19:23:57 -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 55663 invoked by uid 89); 17 Feb 2018 19:23:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 17 Feb 2018 19:23:55 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w1HJNmfp016523 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 17 Feb 2018 14:23:53 -0500 Received: by simark.ca (Postfix, from userid 112) id 8012B1E76B; Sat, 17 Feb 2018 14:23:48 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id A9C3A1E093; Sat, 17 Feb 2018 14:23:43 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 17 Feb 2018 19:23:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Remove a cleanup from call_function_by_hand_dummy In-Reply-To: <20180217161104.4909-1-tom@tromey.com> References: <20180217161104.4909-1-tom@tromey.com> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.4 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 17 Feb 2018 19:23:48 +0000 X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00230.txt.bz2 On 2018-02-17 11:11, Tom Tromey wrote: > This removes a cleanup from call_function_by_hand_dummy, replacing > manual allocation with std::vector. > > Regression tested by the buildbot. > > gdb/ChangeLog > 2018-02-16 Tom Tromey > > * infcall.c (call_function_by_hand_dummy): Use std::vector. > --- > gdb/ChangeLog | 4 ++++ > gdb/infcall.c | 14 ++++---------- > 2 files changed, 8 insertions(+), 10 deletions(-) > > diff --git a/gdb/infcall.c b/gdb/infcall.c > index 8b75297251..6ff725a815 100644 > --- a/gdb/infcall.c > +++ b/gdb/infcall.c > @@ -732,7 +732,6 @@ call_function_by_hand_dummy (struct value > *function, > struct type *ftype = check_typedef (value_type (function)); > CORE_ADDR bp_addr; > struct frame_id dummy_id; > - struct cleanup *args_cleanup; > struct frame_info *frame; > struct gdbarch *gdbarch; > struct cleanup *terminate_bp_cleanup; > @@ -1054,21 +1053,18 @@ call_function_by_hand_dummy (struct value > *function, > } > } > > + std::vector new_args; > if (hidden_first_param_p) > { > - struct value **new_args; > - > /* Add the new argument to the front of the argument list. */ > - new_args = XNEWVEC (struct value *, nargs + 1); > + new_args.reserve (nargs + 1); This should probably be resize instead of reserve. When you call reserve, it doesn't change the actual length of the vector. You could then use a def_vector to avoid unneeded zero-initialization by the resize operation. Other than that, LGTM. Simon