mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
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.
This commit is contained in:
parent
dcf043842e
commit
8872c238ba
41 changed files with 112 additions and 308 deletions
|
|
@ -56,12 +56,7 @@ pa_headerlist* pa_headerlist_new(void) {
|
|||
}
|
||||
|
||||
void pa_headerlist_free(pa_headerlist* p) {
|
||||
struct header *hdr;
|
||||
|
||||
while ((hdr = pa_hashmap_steal_first(MAKE_HASHMAP(p))))
|
||||
header_free(hdr);
|
||||
|
||||
pa_hashmap_free(MAKE_HASHMAP(p), NULL, NULL);
|
||||
pa_hashmap_free(MAKE_HASHMAP(p), (pa_free_cb_t) header_free);
|
||||
}
|
||||
|
||||
int pa_headerlist_puts(pa_headerlist *p, const char *key, const char *value) {
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ static void sink_input_kill(pa_sink_input* i) {
|
|||
pa_sink_input_assert_ref(i);
|
||||
pa_assert_se(s = i->userdata);
|
||||
|
||||
pa_hashmap_remove(s->userdata->by_origin, s->sdp_info.origin);
|
||||
session_free(s);
|
||||
}
|
||||
|
||||
|
|
@ -606,7 +607,6 @@ static void session_free(struct session *s) {
|
|||
PA_LLIST_REMOVE(struct session, s->userdata->sessions, s);
|
||||
pa_assert(s->userdata->n_sessions >= 1);
|
||||
s->userdata->n_sessions--;
|
||||
pa_hashmap_remove(s->userdata->by_origin, s->sdp_info.origin);
|
||||
|
||||
pa_memblockq_free(s->memblockq);
|
||||
pa_sdp_info_destroy(&s->sdp_info);
|
||||
|
|
@ -635,7 +635,7 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event
|
|||
|
||||
if (goodbye) {
|
||||
|
||||
if ((s = pa_hashmap_get(u->by_origin, info.origin)))
|
||||
if ((s = pa_hashmap_remove(u->by_origin, info.origin)))
|
||||
session_free(s);
|
||||
|
||||
pa_sdp_info_destroy(&info);
|
||||
|
|
@ -674,8 +674,10 @@ static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const str
|
|||
|
||||
k = pa_atomic_load(&s->timestamp);
|
||||
|
||||
if (k + DEATH_TIMEOUT < now.tv_sec)
|
||||
if (k + DEATH_TIMEOUT < now.tv_sec) {
|
||||
pa_hashmap_remove(u->by_origin, s->sdp_info.origin);
|
||||
session_free(s);
|
||||
}
|
||||
}
|
||||
|
||||
/* Restart timer */
|
||||
|
|
@ -753,7 +755,6 @@ fail:
|
|||
|
||||
void pa__done(pa_module*m) {
|
||||
struct userdata *u;
|
||||
struct session *s;
|
||||
|
||||
pa_assert(m);
|
||||
|
||||
|
|
@ -768,12 +769,8 @@ void pa__done(pa_module*m) {
|
|||
|
||||
pa_sap_context_destroy(&u->sap_context);
|
||||
|
||||
if (u->by_origin) {
|
||||
while ((s = pa_hashmap_first(u->by_origin)))
|
||||
session_free(s);
|
||||
|
||||
pa_hashmap_free(u->by_origin, NULL, NULL);
|
||||
}
|
||||
if (u->by_origin)
|
||||
pa_hashmap_free(u->by_origin, (pa_free_cb_t) session_free);
|
||||
|
||||
pa_xfree(u->sink_name);
|
||||
pa_xfree(u);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue