aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote-notif.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2023-11-09 21:22:15 +0000
committerPedro Alves <pedro@palves.net>2023-12-20 20:04:16 +0000
commite21633812306a23d454e1a63fa57a5b689cddcbb (patch)
treeeecf6036accd93412d1d1ee77c3ccae63a404627 /gdb/remote-notif.c
parentd5cebea18e7a9a927f4dd4915d093feb7df0e029 (diff)
downloadfsf-binutils-gdb-e21633812306a23d454e1a63fa57a5b689cddcbb.zip
fsf-binutils-gdb-e21633812306a23d454e1a63fa57a5b689cddcbb.tar.gz
fsf-binutils-gdb-e21633812306a23d454e1a63fa57a5b689cddcbb.tar.bz2
Complete use of unique_ptr with notif_event and stop_reply
We already use unique_ptr with notif_event and stop_reply in some places around the remote target, but not fully. There are several code paths that still use raw pointers. This commit makes all of the ownership of these objects tracked by unique pointers, making the lifetime flow much more obvious, IMHO. I notice that it fixes a leak -- in remote_notif_stop_ack, We weren't destroying the stop_reply object if it was of TARGET_WAITKIND_IGNORE kind. Approved-By: Tom Tromey <tom@tromey.com> Change-Id: Id81daf39653d8792c8795b2a145772176bfae77c
Diffstat (limited to 'gdb/remote-notif.c')
-rw-r--r--gdb/remote-notif.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c
index 997b6e7..e932d6a 100644
--- a/gdb/remote-notif.c
+++ b/gdb/remote-notif.c
@@ -67,12 +67,12 @@ remote_notif_ack (remote_target *remote,
nc->ack_command);
nc->parse (remote, nc, buf, event.get ());
- nc->ack (remote, nc, buf, event.release ());
+ nc->ack (remote, nc, buf, std::move (event));
}
/* Parse the BUF for the expected notification NC. */
-struct notif_event *
+notif_event_up
remote_notif_parse (remote_target *remote,
const notif_client *nc, const char *buf)
{
@@ -83,7 +83,7 @@ remote_notif_parse (remote_target *remote,
nc->parse (remote, nc, buf, event.get ());
- return event.release ();
+ return event;
}
/* Process notifications in STATE's notification queue one by one.
@@ -150,12 +150,12 @@ handle_notification (struct remote_notif_state *state, const char *buf)
}
else
{
- struct notif_event *event
+ notif_event_up event
= remote_notif_parse (state->remote, nc, buf + strlen (nc->name) + 1);
/* Be careful to only set it after parsing, since an error
may be thrown then. */
- state->pending_event[nc->id] = event;
+ state->pending_event[nc->id] = std::move (event);
/* Notify the event loop there's a stop reply to acknowledge
and that there may be more events to fetch. */
@@ -230,14 +230,9 @@ remote_notif_state_allocate (remote_target *remote)
remote_notif_state::~remote_notif_state ()
{
- int i;
-
/* Unregister async_event_handler for notification. */
if (get_pending_events_token != NULL)
delete_async_event_handler (&get_pending_events_token);
-
- for (i = 0; i < REMOTE_NOTIF_LAST; i++)
- delete pending_event[i];
}
void _initialize_notif ();