[PATCH] gdbserver: add client_state destructor

Keith Seitz keiths@redhat.com
Fri May 3 13:21:08 GMT 2024


On 5/3/24 05:29, Guinevere Larsen wrote:
> ---
>   gdbserver/server.h | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/gdbserver/server.h b/gdbserver/server.h
> index 0074818c6df..256294b0052 100644
> --- a/gdbserver/server.h
> +++ b/gdbserver/server.h
> @@ -133,6 +133,12 @@ struct client_state
>       own_buf ((char *) xmalloc (PBUFSIZ + 1))
>     {}
>   
> +  ~client_state ()
> +  {
> +    if (own_buf != nullptr)
> +      xfree (own_buf);
> +  }
> +

You don't need to guard xfree -- it deals gracefully with nullptr.

Reviewed-by: Keith Seitz <keiths@redhat.com>

Keith

>     /* The thread set with an `Hc' packet.  `Hc' is deprecated in favor of
>        `vCont'.  Note the multi-process extensions made `vCont' a
>        requirement, so `Hc pPID.TID' is pretty much undefined.  So



More information about the Gdb-patches mailing list