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 2/4] Remove last cleanups from d-exp.y


On 09/06/2017 06:13 AM, Tom Tromey wrote:

> --- a/gdb/d-exp.y
> +++ b/gdb/d-exp.y
> @@ -470,15 +470,15 @@ PrimaryExpression:
>  			      struct block_symbol sym;
>  			      const char *type_name = TYPE_SAFE_NAME (type);
>  			      int type_name_len = strlen (type_name);
> -			      char *name;
> +			      std::string name;
>  
> -			      name = xstrprintf ("%.*s.%.*s",
> -						 type_name_len, type_name,
> -						 $3.length, $3.ptr);
> -			      make_cleanup (xfree, name);
> +			      name = string_printf ("%.*s.%.*s",

You can merge the declaration + initialization here in a single
statement to avoid running the default std::string ctor.  I.e.,:

		      std::string name = string_printf ("%.*s.%.*s",

Otherwise looks fine to me.  Thanks!

Pedro Alves


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