diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2013-02-12 21:36:53 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2013-02-16 01:12:21 +0200 |
commit | 8872c238ba6748c76455ecc6827b83ebcb1dd469 (patch) | |
tree | 1f73094f08088d08ded489f479cbf54ab7769214 /src/modules/alsa/alsa-mixer.c | |
parent | dcf043842e6bef0680bb246e7266b7c0829d34d4 (diff) |
hashmap: Use pa_free_cb_t instead of pa_free2_cb_t
The previous patch removed module-gconf's dependency on the userdata
pointer of the free callback, and that was the only place where the
userdata pointer of pa_free2_cb_t was used, so now there's no need for
pa_free2_cb_t in pa_hashmap_free(). Using pa_free_cb_t instead allows
removing a significant amount of repetitive code.
Diffstat (limited to 'src/modules/alsa/alsa-mixer.c')
-rw-r--r-- | src/modules/alsa/alsa-mixer.c | 56 |
1 files changed, 13 insertions, 43 deletions
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 761aae10e..395ee2c8a 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -530,7 +530,7 @@ void pa_alsa_path_set_free(pa_alsa_path_set *ps) { pa_assert(ps); if (ps->paths) - pa_hashmap_free(ps->paths, NULL, NULL); + pa_hashmap_free(ps->paths, NULL); pa_xfree(ps); } @@ -3300,50 +3300,20 @@ static void profile_free(pa_alsa_profile *p) { void pa_alsa_profile_set_free(pa_alsa_profile_set *ps) { pa_assert(ps); - if (ps->input_paths) { - pa_alsa_path *p; - - while ((p = pa_hashmap_steal_first(ps->input_paths))) - pa_alsa_path_free(p); - - pa_hashmap_free(ps->input_paths, NULL, NULL); - } - - if (ps->output_paths) { - pa_alsa_path *p; - - while ((p = pa_hashmap_steal_first(ps->output_paths))) - pa_alsa_path_free(p); - - pa_hashmap_free(ps->output_paths, NULL, NULL); - } + if (ps->input_paths) + pa_hashmap_free(ps->input_paths, (pa_free_cb_t) pa_alsa_path_free); - if (ps->profiles) { - pa_alsa_profile *p; + if (ps->output_paths) + pa_hashmap_free(ps->output_paths, (pa_free_cb_t) pa_alsa_path_free); - while ((p = pa_hashmap_steal_first(ps->profiles))) - profile_free(p); - - pa_hashmap_free(ps->profiles, NULL, NULL); - } + if (ps->profiles) + pa_hashmap_free(ps->profiles, (pa_free_cb_t) profile_free); - if (ps->mappings) { - pa_alsa_mapping *m; - - while ((m = pa_hashmap_steal_first(ps->mappings))) - mapping_free(m); + if (ps->mappings) + pa_hashmap_free(ps->mappings, (pa_free_cb_t) mapping_free); - pa_hashmap_free(ps->mappings, NULL, NULL); - } - - if (ps->decibel_fixes) { - pa_alsa_decibel_fix *db_fix; - - while ((db_fix = pa_hashmap_steal_first(ps->decibel_fixes))) - decibel_fix_free(db_fix); - - pa_hashmap_free(ps->decibel_fixes, NULL, NULL); - } + if (ps->decibel_fixes) + pa_hashmap_free(ps->decibel_fixes, (pa_free_cb_t) decibel_fix_free); pa_xfree(ps); } @@ -4415,8 +4385,8 @@ void pa_alsa_profile_set_probe( paths_drop_unsupported(ps->input_paths); paths_drop_unsupported(ps->output_paths); - pa_hashmap_free(broken_inputs, NULL, NULL); - pa_hashmap_free(broken_outputs, NULL, NULL); + pa_hashmap_free(broken_inputs, NULL); + pa_hashmap_free(broken_outputs, NULL); ps->probed = TRUE; } |