[RFA v2 15/24] Use containers to avoid cleanups

Simon Marchi simon.marchi@polymtl.ca
Mon Jul 31 19:42:00 GMT 2017


On 2017-07-25 19:20, Tom Tromey wrote:
> @@ -601,24 +599,16 @@ elf_rel_plt_read (minimal_symbol_reader &reader,
>  	 OBJFILE the symbol is undefined and the objfile having NAME defined
>  	 may not yet have been loaded.  */
> 
> -      if (string_buffer_size < name_len + got_suffix_len + 1)
> -	{
> -	  string_buffer_size = 2 * (name_len + got_suffix_len);
> -	  string_buffer = (char *) xrealloc (string_buffer, 
> string_buffer_size);
> -	}
> -      memcpy (string_buffer, name, name_len);
> -      memcpy (&string_buffer[name_len], SYMBOL_GOT_PLT_SUFFIX,
> -	      got_suffix_len + 1);
> +      string_buffer.assign (name, name_len);

You can get rid of the name_len variable and just use

   string_buffer.assign (name);

Otherwise, LGTM.

Simon



More information about the Gdb-patches mailing list