This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 2/4] Remove last cleanups from d-exp.y
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Wed, 6 Sep 2017 20:31:56 +0100
- Subject: Re: [RFA 2/4] Remove last cleanups from d-exp.y
- 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 EF56883F3E
- References: <20170906051306.6092-1-tom@tromey.com> <20170906051306.6092-3-tom@tromey.com>
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