Commit e3dac3eb authored by Philip Withnall's avatar Philip Withnall

agent: Factor out free function for IncomingCheck

parent 21b0fee0
...@@ -61,6 +61,13 @@ static void ...@@ -61,6 +61,13 @@ static void
component_deschedule_io_callback (Component *component); component_deschedule_io_callback (Component *component);
void
incoming_check_free (IncomingCheck *icheck)
{
g_free (icheck->username);
g_slice_free (IncomingCheck, icheck);
}
/* Must *not* take the agent lock, since it’s called from within /* Must *not* take the agent lock, since it’s called from within
* component_set_io_context(), which holds the Component’s I/O lock. */ * component_set_io_context(), which holds the Component’s I/O lock. */
static void static void
...@@ -234,18 +241,13 @@ component_close (Component *cmp) ...@@ -234,18 +241,13 @@ component_close (Component *cmp)
nice_candidate_free (cmp->turn_candidate), nice_candidate_free (cmp->turn_candidate),
cmp->turn_candidate = NULL; cmp->turn_candidate = NULL;
for (i = cmp->incoming_checks; i; i = i->next) {
IncomingCheck *icheck = i->data;
g_free (icheck->username);
g_slice_free (IncomingCheck, icheck);
}
g_slist_free (cmp->local_candidates); g_slist_free (cmp->local_candidates);
cmp->local_candidates = NULL; cmp->local_candidates = NULL;
g_slist_free (cmp->remote_candidates); g_slist_free (cmp->remote_candidates);
cmp->remote_candidates = NULL; cmp->remote_candidates = NULL;
component_free_socket_sources (cmp); component_free_socket_sources (cmp);
g_slist_free (cmp->incoming_checks); g_slist_free_full (cmp->incoming_checks,
(GDestroyNotify) incoming_check_free);
cmp->incoming_checks = NULL; cmp->incoming_checks = NULL;
component_clean_turn_servers (cmp); component_clean_turn_servers (cmp);
...@@ -361,12 +363,8 @@ component_restart (Component *cmp) ...@@ -361,12 +363,8 @@ component_restart (Component *cmp)
g_slist_free (cmp->remote_candidates), g_slist_free (cmp->remote_candidates),
cmp->remote_candidates = NULL; cmp->remote_candidates = NULL;
for (i = cmp->incoming_checks; i; i = i->next) { g_slist_free_full (cmp->incoming_checks,
IncomingCheck *icheck = i->data; (GDestroyNotify) incoming_check_free);
g_free (icheck->username);
g_slice_free (IncomingCheck, icheck);
}
g_slist_free (cmp->incoming_checks);
cmp->incoming_checks = NULL; cmp->incoming_checks = NULL;
/* note: component state managed by agent */ /* note: component state managed by agent */
......
...@@ -96,6 +96,9 @@ struct _IncomingCheck ...@@ -96,6 +96,9 @@ struct _IncomingCheck
uint16_t username_len; uint16_t username_len;
}; };
void
incoming_check_free (IncomingCheck *icheck);
/* A pair of a socket and the GSource which polls it from the main loop. All /* A pair of a socket and the GSource which polls it from the main loop. All
* GSources in a Component must be attached to the same main context: * GSources in a Component must be attached to the same main context:
* component->ctx. * component->ctx.
......
...@@ -1123,12 +1123,8 @@ void conn_check_remote_candidates_set(NiceAgent *agent) ...@@ -1123,12 +1123,8 @@ void conn_check_remote_candidates_set(NiceAgent *agent)
/* Once we process the pending checks, we should free them to avoid /* Once we process the pending checks, we should free them to avoid
* reprocessing them again if a dribble-mode set_remote_candidates * reprocessing them again if a dribble-mode set_remote_candidates
* is called */ * is called */
for (m = component->incoming_checks; m; m = m->next) { g_slist_free_full (component->incoming_checks,
IncomingCheck *icheck = m->data; (GDestroyNotify) incoming_check_free);
g_free (icheck->username);
g_slice_free (IncomingCheck, icheck);
}
g_slist_free (component->incoming_checks);
component->incoming_checks = NULL; component->incoming_checks = NULL;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment