From: Tom Tromey Date: Sun, 16 Jun 2019 16:52:27 +0000 (-0600) Subject: Split the tui_win_info destructor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee1d42d6c1a05725868a8ea4855eaa81cbbda635;p=binutils-gdb.git Split the tui_win_info destructor This patch adds destructors to tui_source_window and tui_data_window, and splits ~tui_win_info as appropriate. gdb/ChangeLog 2019-06-25 Tom Tromey * tui/tui-data.h (struct tui_source_window) (struct tui_data_window): Declare destructors. * tui/tui-data.c (~tui_source_window, ~tui_data_window): New destructors. (tui_win_info): Simplify. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 412c4426035..434d7dda79d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2019-06-25 Tom Tromey + + * tui/tui-data.h (struct tui_source_window) + (struct tui_data_window): Declare destructors. + * tui/tui-data.c (~tui_source_window, ~tui_data_window): New + destructors. + (tui_win_info): Simplify. + 2019-06-25 Tom Tromey * tui/tui-winsource.c (tui_display_main) diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index d9b8bd6aae3..d24941c10da 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -617,47 +617,43 @@ tui_add_content_elements (struct tui_gen_win_info *win_info, return index_start; } -tui_win_info::~tui_win_info () +tui_source_window::~tui_source_window () { - struct tui_gen_win_info *generic_win; + if (detail.source_info.fullname) + { + xfree (detail.source_info.fullname); + detail.source_info.fullname = NULL; + } + struct tui_gen_win_info *generic_win = detail.source_info.execution_info; + if (generic_win != NULL) + { + tui_delete_win (generic_win->handle); + generic_win->handle = NULL; + tui_free_win_content (generic_win); + } +} - switch (generic.type) +tui_data_window::~tui_data_window () +{ + if (generic.content != NULL) { - case SRC_WIN: - case DISASSEM_WIN: - if (detail.source_info.fullname) - { - xfree (detail.source_info.fullname); - detail.source_info.fullname = NULL; - } - generic_win = detail.source_info.execution_info; - if (generic_win != NULL) - { - tui_delete_win (generic_win->handle); - generic_win->handle = NULL; - tui_free_win_content (generic_win); - } - break; - case DATA_WIN: - if (generic.content != NULL) - { - tui_free_data_content (detail.data_display_info.regs_content, - detail.data_display_info.regs_content_count); - detail.data_display_info.regs_content = NULL; - detail.data_display_info.regs_content_count = 0; - tui_free_data_content (detail.data_display_info.data_content, - detail.data_display_info.data_content_count); - detail.data_display_info.data_content = NULL; - detail.data_display_info.data_content_count = 0; - detail.data_display_info.regs_column_count = 1; - detail.data_display_info.display_regs = FALSE; - generic.content = NULL; - generic.content_size = 0; - } - break; - default: - break; + tui_free_data_content (detail.data_display_info.regs_content, + detail.data_display_info.regs_content_count); + detail.data_display_info.regs_content = NULL; + detail.data_display_info.regs_content_count = 0; + tui_free_data_content (detail.data_display_info.data_content, + detail.data_display_info.data_content_count); + detail.data_display_info.data_content = NULL; + detail.data_display_info.data_content_count = 0; + detail.data_display_info.regs_column_count = 1; + detail.data_display_info.display_regs = FALSE; + generic.content = NULL; + generic.content_size = 0; } +} + +tui_win_info::~tui_win_info () +{ if (generic.handle != NULL) { tui_delete_win (generic.handle); diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 80088938543..7adeb5687c9 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -294,6 +294,7 @@ public: struct tui_source_window : public tui_win_info { explicit tui_source_window (enum tui_win_type type); + ~tui_source_window () override; DISABLE_COPY_AND_ASSIGN (tui_source_window); void clear_detail () override; @@ -302,6 +303,7 @@ struct tui_source_window : public tui_win_info struct tui_data_window : public tui_win_info { tui_data_window (); + ~tui_data_window () override; DISABLE_COPY_AND_ASSIGN (tui_data_window); void clear_detail () override;