Remove NULL checks before xfree
authorTom Tromey <tom@tromey.com>
Sun, 23 Jun 2019 20:28:11 +0000 (14:28 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 25 Jun 2019 13:48:51 +0000 (07:48 -0600)
A couple of spots in the TUI did a NULL check before an xfree.  This
isn't necessary, and most other cases were removed from gdb a while
ago.

gdb/ChangeLog
2019-06-25  Tom Tromey  <tom@tromey.com>

* tui/tui-source.c (tui_set_source_content): Don't check before
xfree.
* tui/tui-disasm.c (tui_disassemble): Don't check before xfree.

gdb/ChangeLog
gdb/tui/tui-disasm.c
gdb/tui/tui-source.c

index 2e641249957e77326b4944b35dccda7f65d42d54..9898bcd5c91186deb7b07f2781d4a19a0915ec1d 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-25  Tom Tromey  <tom@tromey.com>
+
+       * tui/tui-source.c (tui_set_source_content): Don't check before
+       xfree.
+       * tui/tui-disasm.c (tui_disassemble): Don't check before xfree.
+
 2019-06-25  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-winsource.h (tui_update_source_window_as_is)
index d3d53d7c607e1d90be040b82996c0a23ae8c348e..4899b1d03cf0a11aa9df59ebb9b21d61e0cb4aaf 100644 (file)
@@ -59,10 +59,8 @@ tui_disassemble (struct gdbarch *gdbarch, struct tui_asm_line *asm_lines,
   /* Now construct each line.  */
   for (; count > 0; count--, asm_lines++)
     {
-      if (asm_lines->addr_string)
-        xfree (asm_lines->addr_string);
-      if (asm_lines->insn)
-        xfree (asm_lines->insn);
+      xfree (asm_lines->addr_string);
+      xfree (asm_lines->insn);
       
       print_address (gdbarch, pc, &gdb_dis_out);
       asm_lines->addr = pc;
index 4f82cbab2dba56f1d720d2986923e06ea9b05265..889b9509fecf6ed97a8e27ba68abae498202e260 100644 (file)
@@ -163,8 +163,7 @@ tui_set_source_content (struct symtab *s,
            = (struct tui_source_window_base *) TUI_SRC_WIN;
          const char *s_filename = symtab_to_filename_for_display (s);
 
-         if (TUI_SRC_WIN->title)
-           xfree (TUI_SRC_WIN->title);
+         xfree (TUI_SRC_WIN->title);
          TUI_SRC_WIN->title = xstrdup (s_filename);
 
          xfree (src->fullname);