From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>, Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 2/3] gdb: have mi_out_new return std::unique_ptr
Date: Mon, 14 Aug 2023 14:42:33 +0100 [thread overview]
Message-ID: <80d10aa41eab1bccd30560880c3547f30331207c.1692019711.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1692019711.git.aburgess@redhat.com>
Have the mi_out_new function return a std::unique_ptr instead of a raw
pointer. Update the two uses of mi_out_new.
There should be no user visible changes after this commit.
---
gdb/mi/mi-interp.c | 2 +-
gdb/mi/mi-main.c | 2 +-
gdb/mi/mi-out.c | 8 ++++----
gdb/mi/mi-out.h | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 0e51c884a65..a7fcf17e51c 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -95,7 +95,7 @@ mi_interp::init (bool top_level)
mi->log = mi->err;
mi->targ = new mi_console_file (mi->raw_stdout, "@", '"');
mi->event_channel = new mi_console_file (mi->raw_stdout, "=", 0);
- mi->mi_uiout = mi_out_new (name ());
+ mi->mi_uiout = mi_out_new (name ()).release ();
gdb_assert (mi->mi_uiout != nullptr);
mi->cli_uiout = new cli_ui_out (mi->out);
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 0ac2c74153d..f9bc1cb9cfb 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2207,7 +2207,7 @@ mi_load_progress (const char *section_name,
which means uiout may not be correct. Fix it for the duration
of this function. */
- std::unique_ptr<ui_out> uiout (mi_out_new (current_interpreter ()->name ()));
+ auto uiout = mi_out_new (current_interpreter ()->name ());
if (uiout == nullptr)
return;
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index 29a416a426d..bbd21287b28 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -336,17 +336,17 @@ mi_ui_out::~mi_ui_out ()
/* See mi/mi-out.h. */
-mi_ui_out *
+std::unique_ptr<mi_ui_out>
mi_out_new (const char *mi_version)
{
if (streq (mi_version, INTERP_MI4) || streq (mi_version, INTERP_MI))
- return new mi_ui_out (4);
+ return gdb::make_unique<mi_ui_out> (4);
if (streq (mi_version, INTERP_MI3))
- return new mi_ui_out (3);
+ return gdb::make_unique<mi_ui_out> (3);
if (streq (mi_version, INTERP_MI2))
- return new mi_ui_out (2);
+ return gdb::make_unique<mi_ui_out> (2);
return nullptr;
}
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index 10c9f8a4585..0dd7479a52f 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -143,7 +143,7 @@ class mi_ui_out : public ui_out
to one of the INTERP_MI* constants (see interps.h).
Return nullptr if an invalid version is provided. */
-mi_ui_out *mi_out_new (const char *mi_version);
+std::unique_ptr<mi_ui_out> mi_out_new (const char *mi_version);
void mi_out_put (ui_out *uiout, struct ui_file *stream);
void mi_out_rewind (ui_out *uiout);
--
2.25.4
next prev parent reply other threads:[~2023-08-14 13:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-14 13:42 [PATCH 0/3] New gdb::make_unique and more std::unique_ptr use Andrew Burgess
2023-08-14 13:42 ` [PATCH 1/3] gdb: add gdb::make_unique function Andrew Burgess
2023-08-14 15:38 ` Tom Tromey
2023-08-17 10:26 ` Andrew Burgess
2023-08-17 18:07 ` Tom Tromey
2023-08-21 10:02 ` Andrew Burgess
2023-08-14 13:42 ` Andrew Burgess [this message]
2023-08-14 13:42 ` [PATCH 3/3] gdb: remove mi_parse::make functions Andrew Burgess
2023-08-22 15:33 ` [PATCH 0/3] New gdb::make_unique and more std::unique_ptr use Tom Tromey
2023-08-23 8:52 ` Andrew Burgess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=80d10aa41eab1bccd30560880c3547f30331207c.1692019711.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).