Use make_unique_xstrdup in TUI
authorTom Tromey <tom@tromey.com>
Tue, 10 Sep 2019 18:56:09 +0000 (12:56 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 20 Sep 2019 19:49:12 +0000 (13:49 -0600)
This changes a couple of spots in the TUI to use make_unique_xstrdup.
This simplifies the code slightly.

gdb/ChangeLog
2019-09-20  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
gdb/tui/tui-disasm.c
gdb/tui/tui-source.c

index 8f69dc59ec35afbfc114f3ffb2f3343c87ffa516..402b57ab6ea3d2cde24d3eeb4d12ad794e5db4b7 100644 (file)
@@ -1,3 +1,10 @@
+2019-09-20  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.
+
 2019-09-20  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-data.c: Remove separator comments.
index 53ea061afb616e0a35d1f167c35c9b9d807a7275..51616bcf8741e2289048973c5ad688883e28e531 100644 (file)
@@ -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;
index fa6ed7893fea279de446169fd66980b38829f659..bb1013bb8694f974540a7d2343f813a6fff625b0 100644 (file)
@@ -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++;