[glib: 6/8] gdbusprivate: Clarify GDBusMessage ownership transfers
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 6/8] gdbusprivate: Clarify GDBusMessage ownership transfers
- Date: Mon, 15 Apr 2019 09:12:02 +0000 (UTC)
commit 1fbf82be1720d4187097834b35c5ecc8f244bde0
Author: Philip Withnall <withnall endlessm com>
Date: Fri Apr 12 16:56:04 2019 +0100
gdbusprivate: Clarify GDBusMessage ownership transfers
Add g_steal_pointer() and g_clear_object() calls in various places to
clarify the ownership transfers for GDBusMessage instances, in a bid to
understand what’s going on in this code and to try to find a
use-after-finalize problem.
This introduces no functional changes, but hopefully makes the code a
little clearer.
Signed-off-by: Philip Withnall <withnall endlessm com>
gio/gdbusprivate.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index dee1f2719..488fe50c4 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -492,9 +492,9 @@ _g_dbus_worker_emit_message_about_to_be_sent (GDBusWorker *worker,
{
GDBusMessage *ret;
if (!g_atomic_int_get (&worker->stopped))
- ret = worker->message_about_to_be_sent_callback (worker, message, worker->user_data);
+ ret = worker->message_about_to_be_sent_callback (worker, g_steal_pointer (&message), worker->user_data);
else
- ret = message;
+ ret = g_steal_pointer (&message);
return ret;
}
@@ -506,13 +506,13 @@ _g_dbus_worker_queue_or_deliver_received_message (GDBusWorker *worker,
if (worker->frozen || g_queue_get_length (worker->received_messages_while_frozen) > 0)
{
/* queue up */
- g_queue_push_tail (worker->received_messages_while_frozen, message);
+ g_queue_push_tail (worker->received_messages_while_frozen, g_steal_pointer (&message));
}
else
{
/* not frozen, nor anything in queue */
_g_dbus_worker_emit_message_received (worker, message);
- g_object_unref (message);
+ g_clear_object (&message);
}
}
@@ -529,7 +529,7 @@ unfreeze_in_idle_cb (gpointer user_data)
while ((message = g_queue_pop_head (worker->received_messages_while_frozen)) != NULL)
{
_g_dbus_worker_emit_message_received (worker, message);
- g_object_unref (message);
+ g_clear_object (&message);
}
worker->frozen = FALSE;
}
@@ -796,7 +796,7 @@ _g_dbus_worker_do_read_cb (GInputStream *input_stream,
}
/* yay, got a message, go deliver it */
- _g_dbus_worker_queue_or_deliver_received_message (worker, message);
+ _g_dbus_worker_queue_or_deliver_received_message (worker, g_steal_pointer (&message));
/* start reading another message! */
worker->read_buffer_bytes_wanted = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]