[RFA 2/4] Remove last cleanups from d-exp.y

Pedro Alves palves@redhat.com
Wed Sep 6 19:32:00 GMT 2017


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



More information about the Gdb-patches mailing list