hashmap: constify hashmap ptr for various functions

This commit is contained in:
Lyndon Brown 2018-05-27 02:27:43 +01:00 committed by Arun Raghavan
parent d0a9eabbac
commit 65450eea2c
2 changed files with 12 additions and 12 deletions

View file

@ -231,7 +231,7 @@ void pa_hashmap_remove_all(pa_hashmap *h) {
} }
} }
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void **key) { void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void **key) {
struct hashmap_entry *e; struct hashmap_entry *e;
pa_assert(h); pa_assert(h);
@ -264,7 +264,7 @@ at_end:
return NULL; return NULL;
} }
void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void **key) { void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void **key) {
struct hashmap_entry *e; struct hashmap_entry *e;
pa_assert(h); pa_assert(h);
@ -297,7 +297,7 @@ at_beginning:
return NULL; return NULL;
} }
void* pa_hashmap_first(pa_hashmap *h) { void* pa_hashmap_first(const pa_hashmap *h) {
pa_assert(h); pa_assert(h);
if (!h->iterate_list_head) if (!h->iterate_list_head)
@ -306,7 +306,7 @@ void* pa_hashmap_first(pa_hashmap *h) {
return h->iterate_list_head->value; return h->iterate_list_head->value;
} }
void* pa_hashmap_last(pa_hashmap *h) { void* pa_hashmap_last(const pa_hashmap *h) {
pa_assert(h); pa_assert(h);
if (!h->iterate_list_tail) if (!h->iterate_list_tail)
@ -329,13 +329,13 @@ void* pa_hashmap_steal_first(pa_hashmap *h) {
return data; return data;
} }
unsigned pa_hashmap_size(pa_hashmap *h) { unsigned pa_hashmap_size(const pa_hashmap *h) {
pa_assert(h); pa_assert(h);
return h->n_entries; return h->n_entries;
} }
bool pa_hashmap_isempty(pa_hashmap *h) { bool pa_hashmap_isempty(const pa_hashmap *h) {
pa_assert(h); pa_assert(h);
return h->n_entries == 0; return h->n_entries == 0;

View file

@ -61,10 +61,10 @@ int pa_hashmap_remove_and_free(pa_hashmap *h, const void *key);
void pa_hashmap_remove_all(pa_hashmap *h); void pa_hashmap_remove_all(pa_hashmap *h);
/* Return the current number of entries of the hashmap */ /* Return the current number of entries of the hashmap */
unsigned pa_hashmap_size(pa_hashmap *h); unsigned pa_hashmap_size(const pa_hashmap *h);
/* Return true if the hashmap is empty */ /* Return true if the hashmap is empty */
bool pa_hashmap_isempty(pa_hashmap *h); bool pa_hashmap_isempty(const pa_hashmap *h);
/* May be used to iterate through the hashmap. Initially the opaque /* May be used to iterate through the hashmap. Initially the opaque
pointer *state has to be set to NULL. The hashmap may not be pointer *state has to be set to NULL. The hashmap may not be
@ -72,19 +72,19 @@ bool pa_hashmap_isempty(pa_hashmap *h);
via pa_hashmap_remove(). The key of the entry is returned in *key, via pa_hashmap_remove(). The key of the entry is returned in *key,
if key is non-NULL. After the last entry in the hashmap NULL is if key is non-NULL. After the last entry in the hashmap NULL is
returned. */ returned. */
void *pa_hashmap_iterate(pa_hashmap *h, void **state, const void**key); void *pa_hashmap_iterate(const pa_hashmap *h, void **state, const void**key);
/* Same as pa_hashmap_iterate() but goes backwards */ /* Same as pa_hashmap_iterate() but goes backwards */
void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void**key); void *pa_hashmap_iterate_backwards(const pa_hashmap *h, void **state, const void**key);
/* Remove the oldest entry in the hashmap and return it */ /* Remove the oldest entry in the hashmap and return it */
void *pa_hashmap_steal_first(pa_hashmap *h); void *pa_hashmap_steal_first(pa_hashmap *h);
/* Return the oldest entry in the hashmap */ /* Return the oldest entry in the hashmap */
void* pa_hashmap_first(pa_hashmap *h); void* pa_hashmap_first(const pa_hashmap *h);
/* Return the newest entry in the hashmap */ /* Return the newest entry in the hashmap */
void* pa_hashmap_last(pa_hashmap *h); void* pa_hashmap_last(const pa_hashmap *h);
/* A macro to ease iteration through all entries */ /* A macro to ease iteration through all entries */
#define PA_HASHMAP_FOREACH(e, h, state) \ #define PA_HASHMAP_FOREACH(e, h, state) \