[PATCH 05/14] Change tui_data_item_window::content to be a unique_xmalloc_ptr

Tom Tromey tom@tromey.com
Tue Aug 20 22:34:00 GMT 2019


>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> On 8/18/19 6:27 PM, Tom Tromey wrote:
>> @@ -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);
>> 

Pedro> Is this related?  

Yeah, though it isn't obvious.  I will amend the commit message to make
this clear.

What is happening here is that the content can only be computed by
tui_register_format, which calls tui_expand_tabs before returning.  So,
it's not possible to see a tab in the contents.

Pedro> (Also, I didn't bother to think through whether strlen
Pedro> is equivalent to the old code.  Is it?)

I think so.

Tom



More information about the Gdb-patches mailing list