From 6bfa88d706cc57a0c975c980dabec5d8ed67dcc0 Mon Sep 17 00:00:00 2001 From: Claudio Takahasi Date: Wed, 12 Mar 2008 21:37:20 +0000 Subject: Keep a list of device's structure pointers instead of paths --- hcid/dbus-hci.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'hcid/dbus-hci.c') diff --git a/hcid/dbus-hci.c b/hcid/dbus-hci.c index 92aed10f..837d47af 100644 --- a/hcid/dbus-hci.c +++ b/hcid/dbus-hci.c @@ -451,7 +451,7 @@ int unregister_adapter_path(const char *path) } if (adapter->devices) { - g_slist_foreach(adapter->devices, (GFunc) free, NULL); + g_slist_foreach(adapter->devices, (GFunc) device_destroy, NULL); g_slist_free(adapter->devices); } @@ -575,11 +575,11 @@ static void create_stored_device(char *key, char *value, void *user_data) { struct adapter *adapter = user_data; GSList *uuids = bt_string2list(value); - const gchar *path; + struct device *device; - path = device_create(adapter, key, uuids); - - adapter->devices = g_slist_append(adapter->devices, g_strdup(path)); + device = device_create(adapter, key, uuids); + if (device) + adapter->devices = g_slist_append(adapter->devices, device); } static void register_devices(bdaddr_t *src, struct adapter *adapter) @@ -783,13 +783,6 @@ int hcid_dbus_stop_device(uint16_t id) adapter->active_conn = NULL; } - if (adapter->devices) { - g_slist_foreach(adapter->devices, (GFunc) device_remove, NULL); - g_slist_foreach(adapter->devices, (GFunc) free, NULL); - g_slist_free(adapter->devices); - adapter->devices = NULL; - } - send_adapter_signal(connection, adapter->dev_id, "ModeChanged", DBUS_TYPE_STRING, &mode, DBUS_TYPE_INVALID); -- cgit