This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA 14/23] Use unique_xmalloc_ptr in jit.c
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Fri, 2 Jun 2017 19:42:29 +0100
- Subject: Re: [RFA 14/23] Use unique_xmalloc_ptr in jit.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 224FE4E358
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 224FE4E358
- References: <20170503224626.2818-1-tom@tromey.com> <20170503224626.2818-15-tom@tromey.com>
On 05/03/2017 11:46 PM, Tom Tromey wrote:
> static void
> jit_reader_load_command (char *args, int from_tty)
> {
> - char *so_name;
> - struct cleanup *prev_cleanup;
> -
> if (args == NULL)
> error (_("No reader name provided."));
> - args = tilde_expand (args);
> - prev_cleanup = make_cleanup (xfree, args);
> + gdb::unique_xmalloc_ptr<char> file (tilde_expand (args));
>
> if (loaded_jit_reader != NULL)
> error (_("JIT reader already loaded. Run jit-reader-unload first."));
>
> - if (IS_ABSOLUTE_PATH (args))
> - so_name = args;
> + gdb::unique_xmalloc_ptr<char> so_name;
> + if (IS_ABSOLUTE_PATH (file.get ()))
> + so_name = std::move (file);
I think we don't really need two unique pointers, and then
moving. I.e., this should do, I think:
if (loaded_jit_reader != NULL)
error (_("JIT reader already loaded. Run jit-reader-unload first."));
gdb::unique_xmalloc_ptr<char> so_name (tilde_expand (args));
if (!IS_ABSOLUTE_PATH (so_name.get ()))
so_name.reset (xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING,
so_name.get ()));
Thanks,
Pedro Alves