This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove a VEC from remote.c


On 2018-11-04 11:06 a.m., Tom Tromey wrote:
> This removes the VEC from remote_g_packet_data, replacing it with a
> std::vector.  This is a bit odd in that this object is never
> destroyed, and is obstack-allocated.  I believe a gdbarch is never
> destroyed, so this seemed ok.

This seems ok to me.  If gdbarch were destroyable, we would need a new
"cleanup" hook to call ~remote_g_packet_data.  But we would need such a
hook even without your patch, to free the VEC, which it itself not allocated
on the gdbarch obstack.

Tiny nit:

> +  data->guesses.push_back (new_guess);

I always prefer having a constructor and using

  data->guesses.emplace_back (bytes, tdesc);

since it makes it impossible to have uninitialized fields by mistake.

Simon

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]