Merge pull request #13 from scossu/const_void_get

Make "key" argument of hashmap_get const void.
pull/11/head v0.4.1
Josh Baker 3 years ago committed by GitHub
commit c546ff8928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,7 +64,7 @@ static void *bucket_item(struct bucket *entry) {
return ((char*)entry)+sizeof(struct bucket); return ((char*)entry)+sizeof(struct bucket);
} }
static uint64_t get_hash(struct hashmap *map, void *key) { static uint64_t get_hash(struct hashmap *map, const void *key) {
return map->hash(key, map->seed0, map->seed1) << 16 >> 16; return map->hash(key, map->seed0, map->seed1) << 16 >> 16;
} }
@ -275,7 +275,7 @@ void *hashmap_set(struct hashmap *map, void *item) {
// hashmap_get returns the item based on the provided key. If the item is not // hashmap_get returns the item based on the provided key. If the item is not
// found then NULL is returned. // found then NULL is returned.
void *hashmap_get(struct hashmap *map, void *key) { void *hashmap_get(struct hashmap *map, const void *key) {
if (!key) { if (!key) {
panic("key is null"); panic("key is null");
} }

@ -33,7 +33,7 @@ void hashmap_free(struct hashmap *map);
void hashmap_clear(struct hashmap *map, bool update_cap); void hashmap_clear(struct hashmap *map, bool update_cap);
size_t hashmap_count(struct hashmap *map); size_t hashmap_count(struct hashmap *map);
bool hashmap_oom(struct hashmap *map); bool hashmap_oom(struct hashmap *map);
void *hashmap_get(struct hashmap *map, void *item); void *hashmap_get(struct hashmap *map, const void *item);
void *hashmap_set(struct hashmap *map, void *item); void *hashmap_set(struct hashmap *map, void *item);
void *hashmap_delete(struct hashmap *map, void *item); void *hashmap_delete(struct hashmap *map, void *item);
void *hashmap_probe(struct hashmap *map, uint64_t position); void *hashmap_probe(struct hashmap *map, uint64_t position);

Loading…
Cancel
Save