diff --git a/common/include/villas/hash_table.h b/common/include/villas/hash_table.h index 9b97066f8..2d8479a92 100644 --- a/common/include/villas/hash_table.h +++ b/common/include/villas/hash_table.h @@ -32,7 +32,7 @@ extern "C" { #endif struct hash_table_entry { - void *key; + const void *key; void *data; struct hash_table_entry *next; @@ -62,20 +62,20 @@ int hash_table_destroy(struct hash_table *ht, dtor_cb_t dtor, bool release); /** Insert a new key/value pair into the hash table. * */ -int hash_table_insert(struct hash_table *ht, void *key, void *data); +int hash_table_insert(struct hash_table *ht, const void *key, void *data); /** Delete a key from the hash table. * * */ -int hash_table_delete(struct hash_table *ht, void *key); +int hash_table_delete(struct hash_table *ht, const void *key); /** Perform a lookup in the hash table. * * @retval != NULL The value for the given key. * @retval NULL The given key is not stored in the hash table. */ -void * hash_table_lookup(struct hash_table *ht, void *key); +void * hash_table_lookup(struct hash_table *ht, const void *key); /** Dump the contents of the hash table in a human readable format to stdout. */ void hash_table_dump(struct hash_table *ht); diff --git a/common/lib/hash_table.c b/common/lib/hash_table.c index d38aa2f15..4fb5da14b 100644 --- a/common/lib/hash_table.c +++ b/common/lib/hash_table.c @@ -25,7 +25,7 @@ #include #include -static int hash_table_hash(struct hash_table *ht, void *key) +static int hash_table_hash(struct hash_table *ht, const void *key) { uintptr_t ptr = (uintptr_t) key; @@ -89,7 +89,7 @@ int hash_table_destroy(struct hash_table *ht, dtor_cb_t dtor, bool release) return 0; } -int hash_table_insert(struct hash_table *ht, void *key, void *data) +int hash_table_insert(struct hash_table *ht, const void *key, void *data) { int ret, ikey = hash_table_hash(ht, key); struct hash_table_entry *hte, *cur; @@ -130,7 +130,7 @@ int hash_table_insert(struct hash_table *ht, void *key, void *data) #include -int hash_table_delete(struct hash_table *ht, void *key) +int hash_table_delete(struct hash_table *ht, const void *key) { int ret, ikey = hash_table_hash(ht, key); struct hash_table_entry *cur, *prev; @@ -163,7 +163,7 @@ int hash_table_delete(struct hash_table *ht, void *key) return ret; } -void * hash_table_lookup(struct hash_table *ht, void *key) +void * hash_table_lookup(struct hash_table *ht, const void *key) { int ikey = hash_table_hash(ht, key); struct hash_table_entry *hte;