mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hash_table: allow constant key
This commit is contained in:
parent
ceeff5e9bb
commit
bf0b8f949e
2 changed files with 8 additions and 8 deletions
|
@ -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);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <villas/utils.h>
|
||||
#include <villas/hash_table.h>
|
||||
|
||||
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 <stdio.h>
|
||||
|
||||
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue