This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Fix memory leak in add_symbol_file_command
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Mon, 14 Aug 2017 14:51:36 +0100
- Subject: Re: [RFA] Fix memory leak in add_symbol_file_command
- Authentication-results: sourceware.org; auth=none
- 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 at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AD5D7787F3
- References: <20170811211846.8455-1-tom@tromey.com>
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<struct sect_opt> 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