[telepathy-gabble/master] Don't lazily alloc/eagerly free delayed_request_streams

Will Thompson will.thompson at collabora.co.uk
Wed Apr 15 09:34:16 PDT 2009


This adds complexity for no gain.
---
 src/media-channel.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/media-channel.c b/src/media-channel.c
index 46a5b83..045d9f7 100644
--- a/src/media-channel.c
+++ b/src/media-channel.c
@@ -162,6 +162,7 @@ gabble_media_channel_init (GabbleMediaChannel *self)
   self->priv = priv;
 
   priv->next_stream_id = 1;
+  priv->delayed_request_streams = g_ptr_array_sized_new (1);
 
   /* initialize properties mixin */
   tp_properties_mixin_init (G_OBJECT (self), G_STRUCT_OFFSET (
@@ -824,7 +825,8 @@ gabble_media_channel_dispose (GObject *object)
     {
       g_ptr_array_foreach (priv->delayed_request_streams,
           (GFunc) destroy_request, NULL);
-      g_assert (priv->delayed_request_streams == NULL);
+      g_ptr_array_free (priv->delayed_request_streams, TRUE);
+      priv->delayed_request_streams = NULL;
     }
 
   tp_handle_unref (contact_handles, priv->creator);
@@ -1730,11 +1732,6 @@ destroy_request (struct _delayed_request_streams_ctx *ctx,
   g_slice_free (struct _delayed_request_streams_ctx, ctx);
   g_ptr_array_remove_fast (priv->delayed_request_streams, ctx);
 
-  if (priv->delayed_request_streams->len == 0)
-    {
-      g_ptr_array_free (priv->delayed_request_streams, TRUE);
-      priv->delayed_request_streams = NULL;
-    }
 }
 
 static void media_channel_request_streams (GabbleMediaChannel *self,
@@ -1803,9 +1800,6 @@ delay_stream_request (GabbleMediaChannel *chan,
           (GSourceFunc) repeat_request, ctx);
     }
 
-  if (priv->delayed_request_streams == NULL)
-      priv->delayed_request_streams = g_ptr_array_sized_new (1);
-
   g_ptr_array_add (priv->delayed_request_streams, ctx);
 }
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list