[Pkg-telepathy-commits] [libnice] 254/265: agent: Tidy up upnp_mapping handling

Simon McVittie smcv at debian.org
Wed May 14 12:05:14 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository libnice.

commit 1d17111ca20c2dec3b5e504bdb7dd6e5667f5ac9
Author: Philip Withnall <philip.withnall at collabora.co.uk>
Date:   Thu Apr 24 15:59:24 2014 +0100

    agent: Tidy up upnp_mapping handling
    
    Use a NULL check to determine if upnp_mapping is an empty list (rather
    than counting every element). Use g_slist_free_full() where appropriate.
    
    This introduces no functional changes.
---
 agent/agent.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/agent/agent.c b/agent/agent.c
index cd6e4ea..73ffb91 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -1971,7 +1971,6 @@ nice_agent_set_relay_info(NiceAgent *agent,
 static gboolean priv_upnp_timeout_cb (gpointer user_data)
 {
   NiceAgent *agent = (NiceAgent*)user_data;
-  GSList *i;
 
   agent_lock();
 
@@ -1982,11 +1981,7 @@ static gboolean priv_upnp_timeout_cb (gpointer user_data)
 
   nice_debug ("Agent %p : UPnP port mapping timed out", agent);
 
-  for (i = agent->upnp_mapping; i; i = i->next) {
-    NiceAddress *a = i->data;
-    nice_address_free (a);
-  }
-  g_slist_free (agent->upnp_mapping);
+  g_slist_free_full (agent->upnp_mapping, (GDestroyNotify) nice_address_free);
   agent->upnp_mapping = NULL;
 
   if (agent->upnp_timer_source != NULL) {
@@ -2054,7 +2049,7 @@ static void _upnp_mapped_external_port (GUPnPSimpleIgd *self, gchar *proto,
   }
 
  end:
-  if (g_slist_length (agent->upnp_mapping) == 0) {
+  if (agent->upnp_mapping == NULL) {
     if (agent->upnp_timer_source != NULL) {
       g_source_destroy (agent->upnp_timer_source);
       g_source_unref (agent->upnp_timer_source);
@@ -2090,7 +2085,7 @@ static void _upnp_error_mapping_port (GUPnPSimpleIgd *self, GError *error,
       }
     }
 
-    if (g_slist_length (agent->upnp_mapping) == 0) {
+    if (agent->upnp_mapping == NULL) {
       if (agent->upnp_timer_source != NULL) {
         g_source_destroy (agent->upnp_timer_source);
         g_source_unref (agent->upnp_timer_source);
@@ -2298,7 +2293,7 @@ nice_agent_gather_candidates (
   /* note: no async discoveries pending, signal that we are ready */
   if (agent->discovery_unsched_items == 0 &&
 #ifdef HAVE_GUPNP
-      g_slist_length (agent->upnp_mapping) == 0) {
+      agent->upnp_mapping == NULL) {
 #else
       TRUE) {
 #endif
@@ -2339,18 +2334,12 @@ nice_agent_gather_candidates (
 static void priv_free_upnp (NiceAgent *agent)
 {
 #ifdef HAVE_GUPNP
-  GSList *i;
-
   if (agent->upnp) {
     g_object_unref (agent->upnp);
     agent->upnp = NULL;
   }
 
-  for (i = agent->upnp_mapping; i; i = i->next) {
-    NiceAddress *a = i->data;
-    nice_address_free (a);
-  }
-  g_slist_free (agent->upnp_mapping);
+  g_slist_free_full (agent->upnp_mapping, (GDestroyNotify) nice_address_free);
   agent->upnp_mapping = NULL;
 
   if (agent->upnp_timer_source != NULL) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/libnice.git



More information about the Pkg-telepathy-commits mailing list