---
 src/modules/alsa/alsa-mixer.c         | 18 ++++++------------
 src/modules/gconf/module-gconf.c      |  6 +-----
 src/modules/module-console-kit.c      |  8 +++-----
 src/modules/module-stream-restore.c   |  7 +++----
 src/modules/module-suspend-on-idle.c  |  5 +----
 src/modules/module-zeroconf-publish.c | 13 +++----------
 src/modules/rtp/headerlist.c          |  8 +-------
 src/modules/rtp/module-rtp-recv.c     | 14 ++++----------
 src/pulse/proplist.c                  |  5 +----
 src/pulsecore/database-simple.c       |  9 +--------
 src/pulsecore/protocol-dbus.c         |  3 +--
 src/pulsecore/sink-input.c            |  6 +-----
 src/pulsecore/sink.c                  |  7 ++-----
 src/pulsecore/source.c                |  4 +---
 14 files changed, 29 insertions(+), 84 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 4357e52..58f9182 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -4296,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);
     }
 }
@@ -4468,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);
     }
 }
 
diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c
index dee15af..3885746 100644
--- a/src/modules/gconf/module-gconf.c
+++ b/src/modules/gconf/module-gconf.c
@@ -289,11 +289,7 @@ static int handle_event(struct userdata *u) {
                 if (!(name = read_string(u)))
                     goto fail;
 
-                if ((m = pa_hashmap_get(u->module_infos, name))) {
-                    pa_hashmap_remove(u->module_infos, name);
-                    module_info_free(m);
-                }
-
+                pa_hashmap_remove_and_free(u->module_infos, name);
                 pa_xfree(name);
 
                 break;
diff --git a/src/modules/module-console-kit.c b/src/modules/module-console-kit.c
index 825fced..0fed15f 100644
--- a/src/modules/module-console-kit.c
+++ b/src/modules/module-console-kit.c
@@ -144,12 +144,10 @@ static void free_session(struct session *session) {
 }
 
 static void remove_session(struct userdata *u, const char *id) {
-    struct session *session;
-
-    if (!(session = pa_hashmap_remove(u->sessions, id)))
-        return;
+    pa_assert(u);
+    pa_assert(id);
 
-    free_session(session);
+    pa_hashmap_remove_and_free(u->sessions, id);
 }
 
 static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *message, 
void *userdata) {
diff --git a/src/modules/module-stream-restore.c 
b/src/modules/module-stream-restore.c
index 5a4bce7..3774d49 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -949,8 +949,7 @@ static void handle_entry_remove(DBusConnection *conn, 
DBusMessage *msg, void *us
     send_entry_removed_signal(de);
     trigger_save(de->userdata);
 
-    pa_assert_se(pa_hashmap_remove(de->userdata->dbus_entries, 
de->entry_name));
-    dbus_entry_free(de);
+    pa_assert_se(pa_hashmap_remove_and_free(de->userdata->dbus_entries, 
de->entry_name) >= 0);
 
     pa_dbus_send_empty_reply(conn, msg);
 }
@@ -2099,7 +2098,7 @@ static int extension_cb(pa_native_protocol *p, pa_module 
*m, pa_native_connectio
 
                 PA_HASHMAP_FOREACH(de, u->dbus_entries, state) {
                     send_entry_removed_signal(de);
-                    dbus_entry_free(pa_hashmap_remove(u->dbus_entries, 
de->entry_name));
+                    pa_hashmap_remove_and_free(u->dbus_entries, 
de->entry_name);
                 }
 #endif
                 pa_database_clear(u->database);
@@ -2213,7 +2212,7 @@ static int extension_cb(pa_native_protocol *p, pa_module 
*m, pa_native_connectio
 #ifdef HAVE_DBUS
                 if ((de = pa_hashmap_get(u->dbus_entries, name))) {
                     send_entry_removed_signal(de);
-                    dbus_entry_free(pa_hashmap_remove(u->dbus_entries, name));
+                    pa_hashmap_remove_and_free(u->dbus_entries, name);
                 }
 #endif
 
diff --git a/src/modules/module-suspend-on-idle.c 
b/src/modules/module-suspend-on-idle.c
index 15cbf95..6fbe640 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -396,14 +396,11 @@ static void device_info_free(struct device_info *d) {
 }
 
 static pa_hook_result_t device_unlink_hook_cb(pa_core *c, pa_object *o, struct 
userdata *u) {
-    struct device_info *d;
-
     pa_assert(c);
     pa_object_assert_ref(o);
     pa_assert(u);
 
-    if ((d = pa_hashmap_remove(u->device_infos, o)))
-        device_info_free(d);
+    pa_hashmap_remove_and_free(u->device_infos, o);
 
     return PA_HOOK_OK;
 }
diff --git a/src/modules/module-zeroconf-publish.c 
b/src/modules/module-zeroconf-publish.c
index db92850..58c5a0b 100644
--- a/src/modules/module-zeroconf-publish.c
+++ b/src/modules/module-zeroconf-publish.c
@@ -375,10 +375,8 @@ static void publish_service(pa_mainloop_api *api 
PA_GCC_UNUSED, void *service) {
 finish:
 
     /* Remove this service */
-    if (r < 0) {
-        pa_hashmap_remove(s->userdata->services, s->key);
-        service_free(s);
-    }
+    if (r < 0)
+        pa_hashmap_remove_and_free(s->userdata->services, s->key);
 
     avahi_string_list_free(txt);
 }
@@ -469,16 +467,11 @@ static pa_hook_result_t device_new_or_changed_cb(pa_core 
*c, pa_object *o, struc
 
 /* Runs in PA mainloop context */
 static pa_hook_result_t device_unlink_cb(pa_core *c, pa_object *o, struct 
userdata *u) {
-    struct service *s;
-
     pa_assert(c);
     pa_object_assert_ref(o);
 
     pa_threaded_mainloop_lock(u->mainloop);
-
-    if ((s = pa_hashmap_remove(u->services, o)))
-        service_free(s);
-
+    pa_hashmap_remove_and_free(u->services, o);
     pa_threaded_mainloop_unlock(u->mainloop);
 
     return PA_HOOK_OK;
diff --git a/src/modules/rtp/headerlist.c b/src/modules/rtp/headerlist.c
index 11e076e..3ed4062 100644
--- a/src/modules/rtp/headerlist.c
+++ b/src/modules/rtp/headerlist.c
@@ -129,16 +129,10 @@ const char *pa_headerlist_gets(pa_headerlist *p, const 
char *key) {
 }
 
 int pa_headerlist_remove(pa_headerlist *p, const char *key) {
-    struct header *hdr;
-
     pa_assert(p);
     pa_assert(key);
 
-    if (!(hdr = pa_hashmap_remove(MAKE_HASHMAP(p), key)))
-        return -1;
-
-    header_free(hdr);
-    return 0;
+    return pa_hashmap_remove_and_free(MAKE_HASHMAP(p), key);
 }
 
 const char *pa_headerlist_iterate(pa_headerlist *p, void **state) {
diff --git a/src/modules/rtp/module-rtp-recv.c 
b/src/modules/rtp/module-rtp-recv.c
index 9dc2feb..e1b6929 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -190,8 +190,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);
+    pa_hashmap_remove_and_free(s->userdata->by_origin, s->sdp_info.origin);
 }
 
 /* Called from IO context */
@@ -647,10 +646,7 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event 
*e, int fd, pa_io_event
         return;
 
     if (goodbye) {
-
-        if ((s = pa_hashmap_remove(u->by_origin, info.origin)))
-            session_free(s);
-
+        pa_hashmap_remove_and_free(u->by_origin, info.origin);
         pa_sdp_info_destroy(&info);
     } else {
 
@@ -687,10 +683,8 @@ 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) {
-            pa_hashmap_remove(u->by_origin, s->sdp_info.origin);
-            session_free(s);
-        }
+        if (k + DEATH_TIMEOUT < now.tv_sec)
+            pa_hashmap_remove_and_free(u->by_origin, s->sdp_info.origin);
     }
 
     /* Restart timer */
diff --git a/src/pulse/proplist.c b/src/pulse/proplist.c
index 0c2bd60..a5ab7d2 100644
--- a/src/pulse/proplist.c
+++ b/src/pulse/proplist.c
@@ -343,18 +343,15 @@ void pa_proplist_update(pa_proplist *p, pa_update_mode_t 
mode, const pa_proplist
 }
 
 int pa_proplist_unset(pa_proplist *p, const char *key) {
-    struct property *prop;
-
     pa_assert(p);
     pa_assert(key);
 
     if (!pa_proplist_key_valid(key))
         return -1;
 
-    if (!(prop = pa_hashmap_remove(MAKE_HASHMAP(p), key)))
+    if (pa_hashmap_remove_and_free(MAKE_HASHMAP(p), key) < 0)
         return -2;
 
-    property_free(prop);
     return 0;
 }
 
diff --git a/src/pulsecore/database-simple.c b/src/pulsecore/database-simple.c
index 562c9ab..155a5fa 100644
--- a/src/pulsecore/database-simple.c
+++ b/src/pulsecore/database-simple.c
@@ -322,18 +322,11 @@ int pa_database_set(pa_database *database, const pa_datum 
*key, const pa_datum*
 
 int pa_database_unset(pa_database *database, const pa_datum *key) {
     simple_data *db = (simple_data*)database;
-    entry *e;
 
     pa_assert(db);
     pa_assert(key);
 
-    e = pa_hashmap_remove(db->map, key);
-    if (!e)
-        return -1;
-
-    free_entry(e);
-
-    return 0;
+    return pa_hashmap_remove_and_free(db->map, key);
 }
 
 int pa_database_clear(pa_database *database) {
diff --git a/src/pulsecore/protocol-dbus.c b/src/pulsecore/protocol-dbus.c
index c0d1ec4..cf4b9fc 100644
--- a/src/pulsecore/protocol-dbus.c
+++ b/src/pulsecore/protocol-dbus.c
@@ -993,8 +993,7 @@ void pa_dbus_protocol_add_signal_listener(
 
         /* Replace the old signal paths entry for this signal with a new
          * one. */
-        if ((signal_paths_entry = 
pa_hashmap_remove(conn_entry->listening_signals, signal_name)))
-            signal_paths_entry_free(signal_paths_entry);
+        pa_hashmap_remove_and_free(conn_entry->listening_signals, signal_name);
         signal_paths_entry = signal_paths_entry_new(signal_name);
 
         for (i = 0; i < n_objects; ++i)
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index fb2a893..b926441 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1324,13 +1324,9 @@ int pa_sink_input_remove_volume_factor(pa_sink_input *i, 
const char *key) {
     pa_assert_ctl_context();
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
 
-    v = pa_hashmap_remove(i->volume_factor_items, key);
-
-    if (!v)
+    if (pa_hashmap_remove_and_free(i->volume_factor_items, key) < 0)
         return -1;
 
-    volume_factor_entry_free(v);
-
     switch (pa_hashmap_size(i->volume_factor_items)) {
         case 0:
             pa_cvolume_reset(&i->volume_factor, i->sample_spec.channels);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 08143e9..b8f85b2 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2554,9 +2554,7 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void 
*userdata, int64_t offse
                 i->thread_info.sync_next = NULL;
             }
 
-            if (pa_hashmap_remove(s->thread_info.inputs, 
PA_UINT32_TO_PTR(i->index)))
-                pa_sink_input_unref(i);
-
+            pa_hashmap_remove_and_free(s->thread_info.inputs, 
PA_UINT32_TO_PTR(i->index));
             pa_sink_invalidate_requested_latency(s, true);
             pa_sink_request_rewind(s, (size_t) -1);
 
@@ -2637,8 +2635,7 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void 
*userdata, int64_t offse
             i->thread_info.attached = false;
 
             /* Let's remove the sink input ...*/
-            if (pa_hashmap_remove(s->thread_info.inputs, 
PA_UINT32_TO_PTR(i->index)))
-                pa_sink_input_unref(i);
+            pa_hashmap_remove_and_free(s->thread_info.inputs, 
PA_UINT32_TO_PTR(i->index));
 
             pa_sink_invalidate_requested_latency(s, true);
 
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 2a600e2..582a923 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -2078,9 +2078,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, 
void *userdata, int64_
                 o->thread_info.direct_on_input = NULL;
             }
 
-            if (pa_hashmap_remove(s->thread_info.outputs, 
PA_UINT32_TO_PTR(o->index)))
-                pa_source_output_unref(o);
-
+            pa_hashmap_remove_and_free(s->thread_info.outputs, 
PA_UINT32_TO_PTR(o->index));
             pa_source_invalidate_requested_latency(s, true);
 
             /* In flat volume mode we need to update the volume as
-- 
1.8.3.1

_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to