Re: [PATCH 01/10] remote: struct remote_state, use op new

Simon Marchi
2018-05-18T20:46:08Z

On 2018-05-16 10:18 AM, Pedro Alves wrote:
> A bit of C++ification.

LGTM, I just noted some questions.
> @@ -657,12 +660,12 @@ struct remote_state
> process it once we're done with sending/receiving the current
> packet, which should be shortly. If however that takes too long,
> and the user presses Ctrl-C again, we offer to disconnect. */
> - int got_ctrlc_during_io;
> + bool got_ctrlc_during_io = false;
>
> /* Descriptor for I/O to remote machine. Initialize it to NULL so that
> remote_open knows that we don't have a file open when the program
> starts. */
> - struct serial *remote_desc;
> + struct serial *remote_desc = nullptr;
>
> /* These are the threads which we last sent to the remote system. The
> TID member will be -1 for all or -2 for not sent yet. */

Should general_thread and continue_thread (below, not shown here) be initialized too?

> @@ -764,6 +767,20 @@ struct remote_thread_info : public private_thread_info
> int vcont_resumed = 0;
> };
>
> +remote_state::remote_state ()
> +{
> + /* The default buffer size is unimportant; it will be expanded
> + whenever a larger buffer is needed. */
> + this->buf_size = 400;
> + this->buf = (char *) xmalloc (this->buf_size);
> +}
> +
> +remote_state::~remote_state ()
> +{
> + xfree (this->last_pass_packet);
> + xfree (this->last_program_signals_packet);

Should other fields be freed here?

- buf
- finished_object
- finished_annex

Simon