[PATCH] gdb: make inferior::terminal a unique ptr

Pedro Alves pedro@palves.net
Thu Jun 25 17:28:36 GMT 2020


On 6/25/20 6:18 PM, Christian Biesinger via Gdb-patches wrote:
> On Thu, Jun 25, 2020 at 10:55 AM Simon Marchi via Gdb-patches
> <gdb-patches@sourceware.org> wrote:
>> -    current_inferior ()->terminal = xstrdup (terminal_name);
>> +    current_inferior ()->terminal.reset (xstrdup (terminal_name));
> 
> Perhaps it really should be a std::string?

I think there's no good reason for that.  It's a string that doesn't
ever need to grow/shrink.  And then its use is to pass down to
a syscall that accepts C-style null-terminated strings:

  tty = open (inferior_thisrun_terminal, O_RDWR | O_NOCTTY);

(and printf logging)

I.e., tracking the string's size doesn't help anything.

Thanks,
Pedro Alves


More information about the Gdb-patches mailing list