diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2013-09-14 11:50:10 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2013-09-17 18:01:22 +0530 |
commit | 6825df8cecb050a42804ad861bf67e8e42f634ea (patch) | |
tree | 00fe32603e74ab562898d9c91fd126bb0b61d9e6 /src/modules/module-suspend-on-idle.c | |
parent | 317b46b57141f81153e3e7a3966cf9fd1119b0b4 (diff) |
hashmap: Add the ability to free keys
Since the hashmap stores a pointer to the key provided at pa_hashmap_put()
time, it make sense to allow the hashmap to be given ownership of the key and
have it free it at pa_hashmap_remove/free time.
To do this cleanly, we now provide the key and value free functions at hashmap
creation time with a pa_hashmap_new_full. With this, we do away with the free
function that was provided at remove/free time for freeing the value.
Diffstat (limited to 'src/modules/module-suspend-on-idle.c')
-rw-r--r-- | src/modules/module-suspend-on-idle.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c index 37ab003c8..0585e51e5 100644 --- a/src/modules/module-suspend-on-idle.c +++ b/src/modules/module-suspend-on-idle.c @@ -447,7 +447,7 @@ int pa__init(pa_module*m) { m->userdata = u = pa_xnew(struct userdata, 1); u->core = m->core; u->timeout = timeout * PA_USEC_PER_SEC; - u->device_infos = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); + u->device_infos = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) device_info_free); PA_IDXSET_FOREACH(sink, m->core->sinks, idx) device_new_hook_cb(m->core, PA_OBJECT(sink), u); @@ -530,7 +530,7 @@ void pa__done(pa_module*m) { if (u->source_output_state_changed_slot) pa_hook_slot_free(u->source_output_state_changed_slot); - pa_hashmap_free(u->device_infos, (pa_free_cb_t) device_info_free); + pa_hashmap_free(u->device_infos); pa_xfree(u); } |