]> git.0d.be Git - empathy.git/commitdiff
Use separate new/free functions for the handler context data
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>
Thu, 9 Sep 2010 10:01:05 +0000 (12:01 +0200)
committerCosimo Cecchi <cosimo.cecchi@collabora.co.uk>
Thu, 9 Sep 2010 10:05:21 +0000 (12:05 +0200)
libempathy/empathy-auth-factory.c

index cfb33c4b327c6907d22868fa731d5abd5991e5cf..fa2b7dcd15ff16b3cf28333fc34bf83f3482caf0 100644 (file)
@@ -55,6 +55,28 @@ typedef struct {
   EmpathyAuthFactory *self;
 } HandlerContextData;
 
+static void
+handler_context_data_free (HandlerContextData *data)
+{
+  tp_clear_object (&data->self);
+  tp_clear_object (&data->context);
+
+  g_slice_free (HandlerContextData, data);
+}
+
+static HandlerContextData *
+handler_context_data_new (EmpathyAuthFactory *self,
+    TpHandleChannelsContext *context)
+{
+  HandlerContextData *data;
+
+  data = g_slice_new0 (HandlerContextData);
+  data->self = g_object_ref (self);
+  data->context = g_object_ref (context);
+
+  return data;
+}
+
 static void
 server_tls_handler_ready_cb (GObject *source,
     GAsyncResult *res,
@@ -85,10 +107,7 @@ server_tls_handler_ready_cb (GObject *source,
       g_object_unref (handler);
     }
 
-  tp_clear_object (&data->context);
-  tp_clear_object (&data->self);
-
-  g_slice_free (HandlerContextData, data);
+  handler_context_data_free (data);
 }
 
 static void
@@ -142,10 +161,7 @@ handle_channels_cb (TpSimpleHandler *handler,
     }
 
   /* create a handler */
-  data = g_slice_new0 (HandlerContextData);
-  data->context = g_object_ref (context);
-  data->self = g_object_ref (self);
-
+  data = handler_context_data_new (self, context);
   tp_handle_channels_context_delay (context);
   empathy_server_tls_handler_new_async (channel, server_tls_handler_ready_cb,
       data);