summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-09-23 14:56:52 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-09-23 15:10:57 +0100
commit4441eea870b6b56b644a750430c145f0ecd7bf9e (patch)
treef4e5cf0080cda2900e91659c0f41dfebf96dc5be
parent67392282f0715859576ce7bb781f18e4b86bf800 (diff)
downloadlibnice-4441eea870b6b56b644a750430c145f0ecd7bf9e.tar.gz
agent: Use g_slist_free_full() to reduce code
This introduces no functional changes.
-rw-r--r--agent/component.c17
-rw-r--r--agent/stream.c12
2 files changed, 6 insertions, 23 deletions
diff --git a/agent/component.c b/agent/component.c
index ca4f209..a720b89 100644
--- a/agent/component.c
+++ b/agent/component.c
@@ -225,20 +225,9 @@ component_clear_selected_pair (Component *component)
void
component_close (Component *cmp)
{
- GSList *i;
IOCallbackData *data;
GOutputVector *vec;
- for (i = cmp->local_candidates; i; i = i->next) {
- NiceCandidate *candidate = i->data;
- nice_candidate_free (candidate);
- }
-
- for (i = cmp->remote_candidates; i; i = i->next) {
- NiceCandidate *candidate = i->data;
- nice_candidate_free (candidate);
- }
-
if (cmp->restart_candidate)
nice_candidate_free (cmp->restart_candidate),
cmp->restart_candidate = NULL;
@@ -247,9 +236,11 @@ component_close (Component *cmp)
nice_candidate_free (cmp->turn_candidate),
cmp->turn_candidate = NULL;
- g_slist_free (cmp->local_candidates);
+ g_slist_free_full (cmp->local_candidates,
+ (GDestroyNotify) nice_candidate_free);
cmp->local_candidates = NULL;
- g_slist_free (cmp->remote_candidates);
+ g_slist_free_full (cmp->remote_candidates,
+ (GDestroyNotify) nice_candidate_free);
cmp->remote_candidates = NULL;
component_free_socket_sources (cmp);
g_slist_free_full (cmp->incoming_checks,
diff --git a/agent/stream.c b/agent/stream.c
index ecc333a..2ce1668 100644
--- a/agent/stream.c
+++ b/agent/stream.c
@@ -80,16 +80,8 @@ stream_close (Stream *stream)
void
stream_free (Stream *stream)
{
- GSList *i;
-
- if (stream->name)
- g_free (stream->name);
- for (i = stream->components; i; i = i->next) {
- Component *component = i->data;
- component_free (component);
- i->data = NULL;
- }
- g_slist_free (stream->components);
+ g_free (stream->name);
+ g_slist_free_full (stream->components, (GDestroyNotify) component_free);
g_slice_free (Stream, stream);
}