This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 02/11] Remove cleanups from mi_cmd_break_insert_1
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Thu, 28 Sep 2017 10:23:55 +0100
- Subject: Re: [RFA 02/11] Remove cleanups from mi_cmd_break_insert_1
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.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 8201CC0D5A48
- References: <20170912185736.20436-1-tom@tromey.com> <20170912185736.20436-3-tom@tromey.com>
On 09/12/2017 07:57 PM, Tom Tromey wrote:
> * target.h (make_scoped_defer_target_commit_resume): Update.
> * target.c (make_scoped_defer_target_commit_resume): Rename from
> make_cleanup_defer_target_commit_resume. Return a
> diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
> index bae8711..4cd134c 100644
> --- a/gdb/mi/mi-cmd-break.c
> +++ b/gdb/mi/mi-cmd-break.c
> @@ -86,12 +86,11 @@ setup_breakpoint_reporting (void)
> /* Convert arguments in ARGV to the string in "format",argv,argv...
> and return it. */
>
> -static char *
> +static std::string
> mi_argv_to_format (char **argv, int argc)
> {
> int i;
> - struct obstack obstack;
> - char *ret;
> + auto_obstack obstack;
>
> obstack_init (&obstack);
Remove the obstack_init call too.
>
> @@ -152,10 +151,7 @@ mi_argv_to_format (char **argv, int argc)
> }
> obstack_1grow (&obstack, '\0');
>
> - ret = xstrdup ((const char *) obstack_finish (&obstack));
> - obstack_free (&obstack, NULL);
> -
> - return ret;
> + return (const char *) obstack_finish (&obstack);
> }
OK.
IMO, it'd be even better to build the std::string directly
instead of building an obstack and then dupping the string.
Thanks,
Pedro Alves