From e7e11af42dca6482302833c4106974176aa66052 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 16 Jun 2019 09:43:21 -0600 Subject: [PATCH] Add destructor to tui_win_info This changes tui_free_window into a destructor for tui_free_window and then updates the users. gdb/ChangeLog 2019-06-25 Tom Tromey * tui/tui-win.c (tui_resize_all): Use delete. * tui/tui-data.h (struct tui_win_info) <~tui_win_info>: Declare destructor. (tui_free_window): Don't declare. * tui/tui-data.c (~tui_win_info): Rename from tui_free_window. Update. --- gdb/ChangeLog | 9 +++++++++ gdb/tui/tui-data.c | 52 +++++++++++++++++++++++++--------------------------- gdb/tui/tui-data.h | 3 ++- gdb/tui/tui-win.c | 2 +- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b4395c0..537c70b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2019-06-25 Tom Tromey + * tui/tui-win.c (tui_resize_all): Use delete. + * tui/tui-data.h (struct tui_win_info) <~tui_win_info>: Declare + destructor. + (tui_free_window): Don't declare. + * tui/tui-data.c (~tui_win_info): Rename from tui_free_window. + Update. + +2019-06-25 Tom Tromey + * tui/tui-data.h (struct tui_win_info): Add constructor. * tui/tui-data.c (tui_alloc_win_info): Use new. (tui_free_window): Use delete. diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 117bda3..1c96fc1 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -603,21 +603,20 @@ tui_add_content_elements (struct tui_gen_win_info *win_info, return index_start; } -void -tui_free_window (struct tui_win_info *win_info) +tui_win_info::~tui_win_info () { struct tui_gen_win_info *generic_win; - switch (win_info->generic.type) + switch (generic.type) { case SRC_WIN: case DISASSEM_WIN: - if (win_info->detail.source_info.fullname) + if (detail.source_info.fullname) { - xfree (win_info->detail.source_info.fullname); - win_info->detail.source_info.fullname = NULL; + xfree (detail.source_info.fullname); + detail.source_info.fullname = NULL; } - generic_win = win_info->detail.source_info.execution_info; + generic_win = detail.source_info.execution_info; if (generic_win != NULL) { tui_delete_win (generic_win->handle); @@ -626,34 +625,33 @@ tui_free_window (struct tui_win_info *win_info) } break; case DATA_WIN: - if (win_info->generic.content != NULL) + if (generic.content != NULL) { - tui_free_data_content (win_info->detail.data_display_info.regs_content, - win_info->detail.data_display_info.regs_content_count); - win_info->detail.data_display_info.regs_content = NULL; - win_info->detail.data_display_info.regs_content_count = 0; - tui_free_data_content (win_info->detail.data_display_info.data_content, - win_info->detail.data_display_info.data_content_count); - win_info->detail.data_display_info.data_content = NULL; - win_info->detail.data_display_info.data_content_count = 0; - win_info->detail.data_display_info.regs_column_count = 1; - win_info->detail.data_display_info.display_regs = FALSE; - win_info->generic.content = NULL; - win_info->generic.content_size = 0; + 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; } - if (win_info->generic.handle != NULL) + if (generic.handle != NULL) { - tui_delete_win (win_info->generic.handle); - win_info->generic.handle = NULL; - tui_free_win_content (&win_info->generic); + tui_delete_win (generic.handle); + generic.handle = NULL; + tui_free_win_content (&generic); } - if (win_info->generic.title) - xfree (win_info->generic.title); - delete win_info; + if (generic.title) + xfree (generic.title); } diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h index 047ee35..c5c2c2b 100644 --- a/gdb/tui/tui-data.h +++ b/gdb/tui/tui-data.h @@ -276,6 +276,8 @@ struct tui_win_info generic.type = type; } + ~tui_win_info (); + DISABLE_COPY_AND_ASSIGN (tui_win_info); struct tui_gen_win_info generic; /* General window information. */ @@ -313,7 +315,6 @@ extern void tui_init_generic_part (struct tui_gen_win_info *); extern tui_win_content tui_alloc_content (int, enum tui_win_type); extern int tui_add_content_elements (struct tui_gen_win_info *, int); -extern void tui_free_window (struct tui_win_info *); extern void tui_free_win_content (struct tui_gen_win_info *); extern void tui_free_data_content (tui_win_content, int); extern void tui_free_all_source_wins_content (void); diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index a1329e5..a69e087 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -785,7 +785,7 @@ tui_resize_all (void) && (tui_win_list[win_type] != NULL) && !tui_win_list[win_type]->generic.is_visible) { - tui_free_window (tui_win_list[win_type]); + delete tui_win_list[win_type]; tui_win_list[win_type] = NULL; } } -- 2.7.4