[Pkg-telepathy-commits] [libnice] 246/265: discovery: Use g_slist_free_full for candidate refresh list

Simon McVittie smcv at debian.org
Wed May 14 12:05:13 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 d510f45d4472930b6f3df9fc35f0b87f9d7a5230
Author: Olivier Crête <olivier.crete at collabora.com>
Date:   Tue Apr 22 17:10:28 2014 -0400

    discovery: Use g_slist_free_full for candidate refresh list
---
 agent/discovery.c | 16 ++++++----------
 agent/discovery.h |  1 -
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/agent/discovery.c b/agent/discovery.c
index 2fa3ea7..35c5a7a 100644
--- a/agent/discovery.c
+++ b/agent/discovery.c
@@ -124,11 +124,10 @@ void discovery_prune_stream (NiceAgent *agent, guint stream_id)
 
 /*
  * Frees the CandidateDiscovery structure pointed to
- * by 'user data'. Compatible with g_slist_foreach().
+ * by 'user data'. Compatible with g_slist_free_full().
  */
-void refresh_free_item (gpointer data, gpointer user_data)
+static void refresh_free_item (CandidateRefresh *cand)
 {
-  CandidateRefresh *cand = data;
   NiceAgent *agent = cand->agent;
   uint8_t *username;
   gsize username_len;
@@ -137,8 +136,6 @@ void refresh_free_item (gpointer data, gpointer user_data)
   size_t buffer_len = 0;
   StunUsageTurnCompatibility turn_compat = agent_to_turn_compatibility (agent);
 
-  g_assert (user_data == NULL);
-
   if (cand->timer_source != NULL) {
     g_source_destroy (cand->timer_source);
     g_source_unref (cand->timer_source);
@@ -200,8 +197,7 @@ void refresh_free_item (gpointer data, gpointer user_data)
  */
 void refresh_free (NiceAgent *agent)
 {
-  g_slist_foreach (agent->refresh_list, refresh_free_item, NULL);
-  g_slist_free (agent->refresh_list);
+  g_slist_free_full (agent->refresh_list, (GDestroyNotify) refresh_free_item);
   agent->refresh_list = NULL;
 }
 
@@ -220,8 +216,8 @@ void refresh_prune_stream (NiceAgent *agent, guint stream_id)
     GSList *next = i->next;
 
     if (cand->stream->id == stream_id) {
-      agent->refresh_list = g_slist_remove (agent->refresh_list, cand);
-      refresh_free_item (cand, NULL);
+      agent->refresh_list = g_slist_delete_link (agent->refresh_list, i);
+      refresh_free_item (cand);
     }
 
     i = next;
@@ -233,7 +229,7 @@ void refresh_cancel (CandidateRefresh *refresh)
 {
   refresh->agent->refresh_list = g_slist_remove (refresh->agent->refresh_list,
       refresh);
-  refresh_free_item (refresh, NULL);
+  refresh_free_item (refresh);
 }
 
 /*
diff --git a/agent/discovery.h b/agent/discovery.h
index 6d848a5..e4cc20a 100644
--- a/agent/discovery.h
+++ b/agent/discovery.h
@@ -82,7 +82,6 @@ typedef struct
   StunMessage stun_resp_msg;
 } CandidateRefresh;
 
-void refresh_free_item (gpointer data, gpointer user_data);
 void refresh_free (NiceAgent *agent);
 void refresh_prune_stream (NiceAgent *agent, guint stream_id);
 void refresh_cancel (CandidateRefresh *refresh);

-- 
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