Patchwork [19/20] Use make_unique_xstrdup in TUI

login
register
mail settings
Submitter Tom Tromey
Date Sept. 10, 2019, 7:08 p.m.
Message ID <20190910190857.6562-20-tom@tromey.com>
Download mbox | patch
Permalink /patch/34488/
State New
Headers show

Comments

Tom Tromey - Sept. 10, 2019, 7:08 p.m.
This changes a couple of spots in the TUI to use make_unique_xstrdup.
This simplifies the code slightly.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tom@tromey.com>

	* tui/tui-source.c (tui_source_window::set_contents): Use
	make_unique_xstrdup.
	* tui/tui-disasm.c (tui_disasm_window::set_contents): Use
	make_unique_xstrdup.
---
 gdb/ChangeLog        | 7 +++++++
 gdb/tui/tui-disasm.c | 2 +-
 gdb/tui/tui-source.c | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 53ea061afb6..51616bcf874 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -218,7 +218,7 @@  tui_disasm_window::set_contents (struct gdbarch *arch,
       if (line.size() > offset)
 	src->line.reset (xstrndup (&line[offset], line_width));
       else
-	src->line.reset (xstrdup (""));
+	src->line = make_unique_xstrdup ("");
 
       src->line_or_addr.loa = LOA_ADDRESS;
       src->line_or_addr.u.addr = asm_lines[i].addr;
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index fa6ed7893fe..bb1013bb869 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -183,7 +183,7 @@  tui_source_window::set_contents (struct gdbarch *arch,
 				 symtab_to_fullname (s)) == 0
 		   && cur_line_no == locator->line_no);
 
-	      content[cur_line].line.reset (xstrdup (text.c_str ()));
+	      content[cur_line].line = make_unique_xstrdup (text.c_str ());
 
 	      cur_line++;
 	      cur_line_no++;