[glib: 2/8] gthreadedsocketservice: Abstract out a free function



commit 63823ae6287427e8ca0560c23f16ab0f5507559d
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Apr 12 15:21:10 2019 +0100

    gthreadedsocketservice: Abstract out a free function
    
    This introduces no functional changes.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 gio/gthreadedsocketservice.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/gio/gthreadedsocketservice.c b/gio/gthreadedsocketservice.c
index 7644d942c..394618f20 100644
--- a/gio/gthreadedsocketservice.c
+++ b/gio/gthreadedsocketservice.c
@@ -75,6 +75,14 @@ typedef struct
   GObject *source_object;
 } GThreadedSocketServiceData;
 
+static void
+g_threaded_socket_service_data_free (GThreadedSocketServiceData *data)
+{
+  g_clear_object (&data->connection);
+  g_clear_object (&data->source_object);
+  g_slice_free (GThreadedSocketServiceData, data);
+}
+
 static void
 g_threaded_socket_service_func (gpointer _data,
                                gpointer user_data)
@@ -86,17 +94,12 @@ g_threaded_socket_service_func (gpointer _data,
   g_signal_emit (threaded, g_threaded_socket_service_run_signal,
                  0, data->connection, data->source_object, &result);
 
-  g_object_unref (data->connection);
-  if (data->source_object)
-    g_object_unref (data->source_object);
-  g_slice_free (GThreadedSocketServiceData, data);
-
   G_LOCK (job_count);
   if (threaded->priv->job_count-- == threaded->priv->max_threads)
     g_socket_service_start (G_SOCKET_SERVICE (threaded));
   G_UNLOCK (job_count);
 
-  g_object_unref (threaded);
+  g_threaded_socket_service_data_free (data);
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]