From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72441 invoked by alias); 14 Aug 2017 13:51:44 -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 72398 invoked by uid 89); 14 Aug 2017 13:51:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Aug 2017 13:51:38 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AD5D7787F3; Mon, 14 Aug 2017 13:51:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AD5D7787F3 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EB8481860; Mon, 14 Aug 2017 13:51:36 +0000 (UTC) Subject: Re: [RFA] Fix memory leak in add_symbol_file_command To: Tom Tromey , gdb-patches@sourceware.org References: <20170811211846.8455-1-tom@tromey.com> From: Pedro Alves Message-ID: <41e0fb1b-2178-4376-4cec-21fe5110e567@redhat.com> Date: Mon, 14 Aug 2017 13:51:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170811211846.8455-1-tom@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-08/txt/msg00293.txt.bz2 Looks fine to me. A couple nits. On 08/11/2017 10:18 PM, Tom Tromey wrote: > struct section_addr_info *section_addrs; > - struct sect_opt *sect_opts = NULL; > - size_t num_sect_opts = 0; > + std::vector sect_opts; Drop "struct" throughout in the new code? You're already dropping it here: > - for (i = 0; i < section_index; i++) > + for (sect_opt § : sect_opts) > @@ -2301,7 +2280,7 @@ add_symbol_file_command (char *args, int from_tty) > filename, and the second is the address where this file has been > loaded. Abort now if this address hasn't been provided by the > user. */ > - if (section_index < 1) > + if (sect_opts.size () < 1) > error (_("The address where %s has been loaded is missing"), > filename.get ()); 'if (sect_opts.empty ())' ? > - for (i = 0; i < section_index; i++) > + for (sect_opt § : sect_opts) > { > CORE_ADDR addr; > - const char *val = sect_opts[i].value; > - const char *sec = sect_opts[i].name; > + const char *val = sect.value; > + const char *sec = sect.name; Thanks, Pedro Alves