[pulseaudio-commits] 2 commits - src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Tue Oct 29 19:49:40 CET 2013
src/modules/bluetooth/bluez5-util.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
New commits:
commit 38b8c42b357c31d847c6715f20ce28fde9fc62a2
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date: Sun Sep 29 18:49:23 2013 +0300
bluetooth: Fix variable constness
The string points to memory inside a DBusMessage, so we don't own the string.
diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 2be15d8..eaff4b1 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -651,7 +651,7 @@ static void parse_adapter_properties(pa_bluetooth_adapter *a, DBusMessageIter *i
dbus_message_iter_recurse(&dict_i, &variant_i);
if (dbus_message_iter_get_arg_type(&variant_i) == DBUS_TYPE_STRING && pa_streq(key, "Address")) {
- char *value;
+ const char *value;
if (is_property_change) {
pa_log_warn("Adapter property 'Address' expected to be constant but changed for %s, ignoring", a->path);
commit c922dce7844793ce1d4724455fb7c54fb5a5fbfe
Author: Tanu Kaskinen <tanu.kaskinen at linux.intel.com>
Date: Sun Sep 29 18:49:22 2013 +0300
bluetooth: Remove adapter_remove_all()
The function was redundant, because all it did was call adapter_free()
for each adapter in the hashmap, and that can be delegated to
pa_hashmap when freeing or emptying it.
diff --git a/src/modules/bluetooth/bluez5-util.c b/src/modules/bluetooth/bluez5-util.c
index 225e5c8..2be15d8 100644
--- a/src/modules/bluetooth/bluez5-util.c
+++ b/src/modules/bluetooth/bluez5-util.c
@@ -492,17 +492,6 @@ static void adapter_remove(pa_bluetooth_discovery *y, const char *path) {
}
}
-static void adapter_remove_all(pa_bluetooth_discovery *y) {
- pa_bluetooth_adapter *a;
-
- pa_assert(y);
-
- /* When this function is called all devices have already been freed */
-
- while ((a = pa_hashmap_steal_first(y->adapters)))
- adapter_free(a);
-}
-
static void parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i, bool is_property_change) {
const char *key;
DBusMessageIter variant_i;
@@ -915,7 +904,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
if (old_owner && *old_owner) {
pa_log_debug("Bluetooth daemon disappeared");
device_remove_all(y);
- adapter_remove_all(y);
+ pa_hashmap_remove_all(y->adapters);
y->objects_listed = false;
}
@@ -1517,7 +1506,8 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
y = pa_xnew0(pa_bluetooth_discovery, 1);
PA_REFCNT_INIT(y);
y->core = c;
- y->adapters = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
+ y->adapters = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL,
+ (pa_free_cb_t) adapter_free);
y->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
y->transports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
PA_LLIST_HEAD_INIT(pa_dbus_pending, y->pending);
@@ -1598,10 +1588,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
pa_hashmap_free(y->devices);
}
- if (y->adapters) {
- adapter_remove_all(y);
+ if (y->adapters)
pa_hashmap_free(y->adapters);
- }
if (y->transports) {
pa_assert(pa_hashmap_isempty(y->transports));
More information about the pulseaudio-commits
mailing list