]> code.delx.au - pulseaudio/blobdiff - src/modules/alsa/alsa-mixer.c
Use pa_hashmap_remove_and_free() where appropriate
[pulseaudio] / src / modules / alsa / alsa-mixer.c
index 95c7628db400ac98664d7f206bc023e03bd9fbfc..58f91820cbe42e97bc953c6c827d520c92c538b7 100644 (file)
@@ -523,6 +523,7 @@ void pa_alsa_path_free(pa_alsa_path *p) {
     pa_proplist_free(p->proplist);
     pa_xfree(p->name);
     pa_xfree(p->description);
+    pa_xfree(p->description_key);
     pa_xfree(p);
 }
 
@@ -2574,7 +2575,7 @@ static bool element_create_settings(pa_alsa_element *e, pa_alsa_setting *templat
 
         if (template) {
             s = pa_xnewdup(pa_alsa_setting, template, 1);
-            s->options = pa_idxset_copy(template->options);
+            s->options = pa_idxset_copy(template->options, NULL);
             s->name = pa_sprintf_malloc("%s+%s", template->name, o->name);
             s->description =
                 (template->description[0] && o->description[0])
@@ -3775,8 +3776,8 @@ static void mapping_paths_probe(pa_alsa_mapping *m, pa_alsa_profile *profile,
     pa_assert(pcm_handle);
 
     mixer_handle = pa_alsa_open_mixer_for_pcm(pcm_handle, NULL, &hctl_handle);
-    if (!mixer_handle || !hctl_handle) {
-         /* Cannot open mixer, remove all entries */
+    if (!mixer_handle) {
+        /* Cannot open mixer, remove all entries */
         pa_hashmap_remove_all(ps->paths);
         return;
     }
@@ -4295,10 +4296,8 @@ static void paths_drop_unused(pa_hashmap* h, pa_hashmap *keep) {
 
     p = pa_hashmap_iterate(h, &state, &key);
     while (p) {
-        if (pa_hashmap_get(keep, p) == NULL) {
-            pa_hashmap_remove(h, key);
-            pa_alsa_path_free(p);
-        }
+        if (pa_hashmap_get(keep, p) == NULL)
+            pa_hashmap_remove_and_free(h, key);
         p = pa_hashmap_iterate(h, &state, &key);
     }
 }
@@ -4467,17 +4466,13 @@ void pa_alsa_profile_set_drop_unsupported(pa_alsa_profile_set *ps) {
     void *state;
 
     PA_HASHMAP_FOREACH(p, ps->profiles, state) {
-        if (!p->supported) {
-            pa_hashmap_remove(ps->profiles, p->name);
-            profile_free(p);
-        }
+        if (!p->supported)
+            pa_hashmap_remove_and_free(ps->profiles, p->name);
     }
 
     PA_HASHMAP_FOREACH(m, ps->mappings, state) {
-        if (m->supported <= 0) {
-            pa_hashmap_remove(ps->mappings, m->name);
-            mapping_free(m);
-        }
+        if (m->supported <= 0)
+            pa_hashmap_remove_and_free(ps->mappings, m->name);
     }
 }