This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Fix memory leak in add_symbol_file_command


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 : 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 : 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]