]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/hashmap.h
remap: Make resampler's remap structure more self-contained
[pulseaudio] / src / pulsecore / hashmap.h
index ae030eda83eb0efd39237863f261f524f059b125..8042f7bd9d87ea4747c1b48803662067233c8040 100644 (file)
@@ -52,6 +52,13 @@ void* pa_hashmap_get(pa_hashmap *h, const void *key);
 /* Returns the data of the entry while removing */
 void* pa_hashmap_remove(pa_hashmap *h, const void *key);
 
+/* Removes the entry and frees the entry data. Returns a negative value if the
+ * entry is not found. FIXME: This function shouldn't be needed.
+ * pa_hashmap_remove() should free the entry data, and the current semantics of
+ * pa_hashmap_remove() should be implemented by a function called
+ * pa_hashmap_steal(). */
+int pa_hashmap_remove_and_free(pa_hashmap *h, const void *key);
+
 /* Remove all entries but don't free the hashmap */
 void pa_hashmap_remove_all(pa_hashmap *h);
 
@@ -85,6 +92,10 @@ void* pa_hashmap_last(pa_hashmap *h);
 #define PA_HASHMAP_FOREACH(e, h, state) \
     for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), NULL); (e); (e) = pa_hashmap_iterate((h), &(state), NULL))
 
+/* A macro to ease itration through all key, value pairs */
+#define PA_HASHMAP_FOREACH_KV(k, e, h, state) \
+    for ((state) = NULL, (e) = pa_hashmap_iterate((h), &(state), (const void **) &(k)); (e); (e) = pa_hashmap_iterate((h), &(state), (const void **) &(k)))
+
 /* A macro to ease iteration through all entries, backwards */
 #define PA_HASHMAP_FOREACH_BACKWARDS(e, h, state) \
     for ((state) = NULL, (e) = pa_hashmap_iterate_backwards((h), &(state), NULL); (e); (e) = pa_hashmap_iterate_backwards((h), &(state), NULL))