[empathy] Use separate new/free functions for the handler context data



commit 1df0a982198b8bd8cec867708dd65b8b7373acee
Author: Cosimo Cecchi <cosimo cecchi collabora co uk>
Date:   Thu Sep 9 12:01:05 2010 +0200

    Use separate new/free functions for the handler context data

 libempathy/empathy-auth-factory.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/libempathy/empathy-auth-factory.c b/libempathy/empathy-auth-factory.c
index cfb33c4..fa2b7dc 100644
--- a/libempathy/empathy-auth-factory.c
+++ b/libempathy/empathy-auth-factory.c
@@ -56,6 +56,28 @@ typedef struct {
 } 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,
     gpointer user_data)
@@ -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);



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