diff options
author | Tom Tromey <tom@tromey.com> | 2019-07-13 16:01:34 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-08-20 16:45:50 -0600 |
commit | b9ad36868f46d5270347ef50fd62fde94d68328b (patch) | |
tree | 6962281859638702bcfe090465937a2b6ab51134 /gdb/tui/tui-regs.c | |
parent | 8e114aab8bdab9a988dfc0afbb3fecc17e2d45b6 (diff) | |
download | binutils-b9ad36868f46d5270347ef50fd62fde94d68328b.zip binutils-b9ad36868f46d5270347ef50fd62fde94d68328b.tar.gz binutils-b9ad36868f46d5270347ef50fd62fde94d68328b.tar.bz2 |
Change tui_data_item_window::content to be a unique_xmalloc_ptr
This changes tui_data_item_window::content to be a unique_xmalloc_ptr
and fixes up the fallout. It also removes a parameter from
tui_expand_tabs, as it was only ever given one value.
This also removes some tab-handling code from
tui_data_window::display_registers_from. Because the content can only
be set by tui_register_format, and because that calls tui_expand_tabs,
it's not possible to see a tab here.
gdb/ChangeLog
2019-08-20 Tom Tromey <tom@tromey.com>
* tui/tui-regs.h (struct tui_data_item_window)
<~tui_data_item_window>: Remove.
<content>: Now a unique_xmalloc_ptr.
* tui/tui-regs.c (tui_register_format): Return a
unique_xmalloc_ptr.
(tui_get_register): Update.
(~tui_data_item_window): Remove.
(tui_data_window::display_registers_from, tui_display_register):
Update.
* tui/tui-io.h (tui_expand_tabs): Update.
* tui/tui-io.c (tui_expand_tabs): Return a unique_xmalloc_ptr.
Remove "col" parameter.
Diffstat (limited to 'gdb/tui/tui-regs.c')
-rw-r--r-- | gdb/tui/tui-regs.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index aebea49..a899b1d 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -52,7 +52,7 @@ static void tui_show_register_group (tui_data_window *win_info, /* Get the register from the frame and return a printable representation of it. */ -static char * +static gdb::unique_xmalloc_ptr<char> tui_register_format (struct frame_info *frame, int regnum) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -72,7 +72,7 @@ tui_register_format (struct frame_info *frame, int regnum) str.resize (str.size () - 1); /* Expand tabs into spaces, since ncurses on MS-Windows doesn't. */ - return tui_expand_tabs (str.c_str (), 0); + return tui_expand_tabs (str.c_str ()); } /* Get the register value from the given frame and format it for the @@ -87,27 +87,19 @@ tui_get_register (struct frame_info *frame, *changedp = false; if (target_has_registers) { - char *prev_content = data->content; - - data->content = tui_register_format (frame, regnum); + gdb::unique_xmalloc_ptr<char> new_content + = tui_register_format (frame, regnum); if (changedp != NULL - && strcmp (prev_content, data->content) != 0) + && strcmp (data->content.get (), new_content.get ()) != 0) *changedp = true; - xfree (prev_content); + data->content = std::move (new_content); } } /* See tui-regs.h. */ -tui_data_item_window::~tui_data_item_window () -{ - xfree (content); -} - -/* See tui-regs.h. */ - int tui_data_window::last_regs_line_no () const { @@ -309,19 +301,13 @@ tui_data_window::display_registers_from (int start_element_no) int max_len = 0; for (auto &&data_item_win : regs_content) { - char *p; + const char *p; int len; len = 0; - p = data_item_win->content; + p = data_item_win->content.get (); if (p != 0) - while (*p) - { - if (*p++ == '\t') - len = 8 * ((len / 8) + 1); - else - len++; - } + len = strlen (p); if (len > max_len) max_len = len; @@ -641,7 +627,7 @@ tui_display_register (struct tui_data_item_window *data) waddch (data->handle, ' '); wmove (data->handle, 0, 0); if (data->content) - waddstr (data->handle, data->content); + waddstr (data->handle, data->content.get ()); if (data->highlight) /* We ignore the return value, casting it to void in order to avoid |