diff --git a/audio/a2dp.c b/audio/a2dp.c
index f3e7af3..4fbd651 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
setups = g_slist_remove(setups, s);
if (s->session)
avdtp_unref(s->session);
- g_slist_foreach(s->cb, (GFunc) g_free, NULL);
- g_slist_free(s->cb);
- g_slist_foreach(s->caps, (GFunc) g_free, NULL);
- g_slist_free(s->caps);
+ g_slist_free_full(s->cb, g_free);
+ g_slist_free_full(s->caps, g_free);
g_free(s);
}
if (!server)
return;
- g_slist_foreach(server->sinks, (GFunc) a2dp_remove_sep, NULL);
- g_slist_free(server->sinks);
-
- g_slist_foreach(server->sources, (GFunc) a2dp_remove_sep, NULL);
- g_slist_free(server->sources);
+ g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_remove_sep);
+ g_slist_free_full(server->sources, (GDestroyNotify) a2dp_remove_sep);
avdtp_exit(src);
/* Copy given caps if they are different than current caps */
if (setup->caps != caps) {
- g_slist_foreach(setup->caps, (GFunc) g_free, NULL);
- g_slist_free(setup->caps);
+ g_slist_free_full(setup->caps, g_free);
setup->caps = g_slist_copy(caps);
}
diff --git a/audio/avdtp.c b/audio/avdtp.c
index 44df636..e8a4007 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
if (stream->io_id)
g_source_remove(stream->io_id);
- g_slist_foreach(stream->callbacks, (GFunc) g_free, NULL);
- g_slist_free(stream->callbacks);
-
- g_slist_foreach(stream->caps, (GFunc) g_free, NULL);
- g_slist_free(stream->caps);
+ g_slist_free_full(stream->callbacks, g_free);
+ g_slist_free_full(stream->caps, g_free);
g_free(stream);
}
if (session->req)
pending_req_free(session->req);
- g_slist_foreach(session->seps, (GFunc) g_free, NULL);
- g_slist_free(session->seps);
+ g_slist_free_full(session->seps, g_free);
g_free(session->buf);
sep->type, sep->media_type);
if (sep->caps) {
- g_slist_foreach(sep->caps, (GFunc) g_free, NULL);
- g_slist_free(sep->caps);
+ g_slist_free_full(sep->caps, g_free);
sep->caps = NULL;
sep->codec = NULL;
sep->delay_reporting = FALSE;
diff --git a/audio/headset.c b/audio/headset.c
index 5a38877..8e63afc 100644
--- a/audio/headset.c
+++ b/audio/headset.c
g_slist_foreach(p->callbacks, (GFunc) pending_connect_complete, dev);
- g_slist_foreach(p->callbacks, (GFunc) g_free, NULL);
- g_slist_free(p->callbacks);
+ g_slist_free_full(p->callbacks, g_free);
if (p->io) {
g_io_channel_shutdown(p->io, TRUE, NULL);
return btd_error_invalid_args(msg);
}
+
static GDBusMethodTable headset_methods[] = {
{ "Connect", "", "", hs_connect,
G_DBUS_METHOD_FLAG_ASYNC },
headset_close_rfcomm(dev);
- g_slist_foreach(hs->nrec_cbs, (GFunc) g_free, NULL);
- g_slist_free(hs->nrec_cbs);
+ g_slist_free_full(hs->nrec_cbs, g_free);
g_free(hs);
dev->headset = NULL;
diff --git a/audio/media.c b/audio/media.c
index bbb77cf..a58e96f 100644
--- a/audio/media.c
+++ b/audio/media.c
{
struct media_adapter *adapter = data;
- g_slist_foreach(adapter->endpoints, (GFunc) media_endpoint_release,
- NULL);
- g_slist_free(adapter->endpoints);
+ g_slist_free_full(adapter->endpoints,
+ (GDestroyNotify) media_endpoint_release);
dbus_connection_unref(adapter->conn);
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index cad4475..14d1ead 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
}
}
-static void pending_req_finalize(struct pending_req *req)
+static void pending_req_finalize(void *data)
{
+ struct pending_req *req = data;
+
if (!dbus_pending_call_get_completed(req->call))
dbus_pending_call_cancel(req->call);
}
}
-static void csd_call_free(struct csd_call *call)
+static void csd_call_free(void *data)
{
+ struct csd_call *call = data;
+
if (!call)
return;
g_slist_free(active_calls);
active_calls = NULL;
- g_slist_foreach(calls, (GFunc) csd_call_free, NULL);
- g_slist_free(calls);
+ g_slist_free_full(calls, csd_call_free);
calls = NULL;
- g_slist_foreach(pending, (GFunc) pending_req_finalize, NULL);
- g_slist_free(pending);
+ g_slist_free_full(pending, pending_req_finalize);
pending = NULL;
- g_slist_foreach(watches, (GFunc) remove_watch, NULL);
- g_slist_free(watches);
+ g_slist_free_full(pending, remove_watch);
watches = NULL;
dbus_connection_unref(connection);
diff --git a/audio/telephony-ofono.c b/audio/telephony-ofono.c
index 20dc907..e72734c 100644
--- a/audio/telephony-ofono.c
+++ b/audio/telephony-ofono.c
return type == DBUS_TYPE_INVALID ? TRUE : FALSE;
}
-static void call_free(struct voice_call *vc)
+static void call_free(void *data)
{
+ struct voice_call *vc = data;
+
DBG("%s", vc->obj_path);
if (vc->status == CALL_STATUS_ACTIVE)
DBG("%s", path);
- g_slist_foreach(calls, (GFunc) call_free, NULL);
- g_slist_free(calls);
+ g_slist_free_full(calls, call_free);
calls = NULL;
g_free(net.operator_name);
g_dbus_remove_watch(connection, GPOINTER_TO_UINT(data));
}
+static void pending_free(void *data)
+{
+ DBusPendingCall *call = data;
+
+ if (!dbus_pending_call_get_completed(call))
+ dbus_pending_call_cancel(call);
+
+ dbus_pending_call_unref(call);
+}
+
void telephony_exit(void)
{
DBG("");
if (modem_obj_path)
modem_removed(modem_obj_path);
- g_slist_foreach(watches, (GFunc) remove_watch, NULL);
- g_slist_free(watches);
+ g_slist_free_full(watches, remove_watch);
watches = NULL;
- g_slist_foreach(pending, (GFunc) dbus_pending_call_cancel, NULL);
- g_slist_foreach(pending, (GFunc) dbus_pending_call_unref, NULL);
- g_slist_free(pending);
+ g_slist_free_full(pending, pending_free);
pending = NULL;
dbus_connection_unref(connection);
diff --git a/audio/unix.c b/audio/unix.c
index b29f5f5..8ce50b0 100644
--- a/audio/unix.c
+++ b/audio/unix.c
static int unix_sock = -1;
-static void client_free(struct unix_client *client)
+static void client_free(void *data)
{
+ struct unix_client *client = data;
+
DBG("client_free(%p)", client);
if (client->cancel && client->dev && client->req_id > 0)
if (client->sock >= 0)
close(client->sock);
- if (client->caps) {
- g_slist_foreach(client->caps, (GFunc) g_free, NULL);
- g_slist_free(client->caps);
- }
+ g_slist_free_full(client->caps, g_free);
g_free(client->interface);
g_free(client);
!g_str_equal(client->interface, AUDIO_SOURCE_INTERFACE))
return -EIO;
- if (client->caps) {
- g_slist_foreach(client->caps, (GFunc) g_free, NULL);
- g_slist_free(client->caps);
- client->caps = NULL;
- }
+ g_slist_free_full(client->caps, g_free);
+ client->caps = NULL;
media_transport = avdtp_service_cap_new(AVDTP_MEDIA_TRANSPORT,
NULL, 0);
void unix_exit(void)
{
- g_slist_foreach(clients, (GFunc) client_free, NULL);
- g_slist_free(clients);
+ g_slist_free_full(clients, client_free);
if (unix_sock >= 0) {
close(unix_sock);
unix_sock = -1;