From 32603266e5688718faad35b7502aa0b72a42764a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 23 Jan 2019 22:16:53 -0700 Subject: C++ify remote notification code This C++ifies the remote notification code -- replacing function pointers with virtual methods and using unique_ptr. This allows for the removal of some cleanups. 2019-03-06 Tom Tromey * remote.c (struct stop_reply_deleter): Remove. (stop_reply_up): Update. (struct stop_reply): Derive from notif_event. Don't typedef. : Now a std::vector. (stop_reply_xfree): Remove. (stop_reply::~stop_reply): Rename from stop_reply_dtr. (remote_notif_stop_alloc_reply): Return a unique_ptr. Use new. (remote_target::discard_pending_stop_replies): Use delete. (remote_target::remote_parse_stop_reply): Update. (remote_target::process_stop_reply): Update. * remote-notif.h (struct notif_event): Add virtual destructor. Remove "dtr" member. (struct notif_client) : Return a unique_ptr. (notif_event_xfree): Don't declare. (notif_event_up): New typedef. * remote-notif.c (remote_notif_ack, remote_notif_parse): Update. (notif_event_xfree, do_notif_event_xfree): Remove. (remote_notif_state_xfree): Update. --- gdb/remote-notif.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'gdb/remote-notif.h') diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h index d766327..87b52a1 100644 --- a/gdb/remote-notif.h +++ b/gdb/remote-notif.h @@ -20,17 +20,22 @@ #ifndef REMOTE_NOTIF_H #define REMOTE_NOTIF_H +#include #include "common/queue.h" /* An event of a type of async remote notification. */ struct notif_event { - /* Destructor. Release everything from SELF, but not SELF - itself. */ - void (*dtr) (struct notif_event *self); + virtual ~notif_event () + { + } }; +/* A unique pointer holding a notif_event. */ + +typedef std::unique_ptr notif_event_up; + /* ID of the notif_client. */ enum REMOTE_NOTIF_ID @@ -70,7 +75,7 @@ typedef struct notif_client struct notif_client *self); /* Allocate an event. */ - struct notif_event *(*alloc_event) (void); + notif_event_up (*alloc_event) (); /* Id of this notif_client. */ const enum REMOTE_NOTIF_ID id; @@ -112,8 +117,6 @@ struct notif_event *remote_notif_parse (remote_target *remote, notif_client *nc, const char *buf); -void notif_event_xfree (struct notif_event *event); - void handle_notification (struct remote_notif_state *notif_state, const char *buf); -- cgit v1.1