From 0b72cde372f4ac58d3027e94ac48672a5698d80a Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Thu, 10 Aug 2023 17:57:46 +0100 Subject: gdb: add gdb::make_unique function While GDB is still C++11, lets add a gdb::make_unique template function that can be used to create std::unique_ptr objects, just like the C++14 std::make_unique. If GDB is being compiled with a C++14 compiler then the new gdb::make_unique function will delegate to the std::make_unique. I checked with gcc, and at -O1 and above gdb::make_unique will be optimised away completely in this case. If C++14 (or later) becomes our minimum, then it will be easy enough to go through the code and replace gdb::make_unique with std::make_unique later on. I've make use of this function in all the places I think this can easily be used, though I'm sure I've probably missed some. Should be no user visible changes after this commit. Approved-By: Tom Tromey --- gdb/ui-out.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gdb/ui-out.c') diff --git a/gdb/ui-out.c b/gdb/ui-out.c index 9380630..b4b8e48 100644 --- a/gdb/ui-out.c +++ b/gdb/ui-out.c @@ -236,9 +236,9 @@ void ui_out_table::append_header (int width, ui_align alignment, internal_error (_("table header must be specified after table_begin and " "before table_body.")); - std::unique_ptr header (new ui_out_hdr (m_headers.size () + 1, - width, alignment, - col_name, col_hdr)); + auto header = gdb::make_unique (m_headers.size () + 1, + width, alignment, + col_name, col_hdr); m_headers.push_back (std::move (header)); } @@ -328,7 +328,7 @@ ui_out::current_level () const void ui_out::push_level (ui_out_type type) { - std::unique_ptr level (new ui_out_level (type)); + auto level = gdb::make_unique (type); m_levels.push_back (std::move (level)); } -- cgit v1.1