From 4cd660ffd59f013d2199fc690a1bd5b02b2e3a7f Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 4 Sep 2024 15:30:37 +0900 Subject: [PATCH] hash_map: Use const where applicable --- src/data_structures/hash_map.c | 6 +++--- src/data_structures/hash_map.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/data_structures/hash_map.c b/src/data_structures/hash_map.c index 50dc646..6fae866 100644 --- a/src/data_structures/hash_map.c +++ b/src/data_structures/hash_map.c @@ -75,7 +75,7 @@ int simple_archiver_hash_map_internal_pick_in_list(void *data, void *ud) { } unsigned long long simple_archiver_hash_map_internal_key_to_hash( - void *key, unsigned int key_size) { + const void *key, unsigned int key_size) { unsigned long long seed = 0; unsigned long long temp = 0; unsigned int count = 0; @@ -213,8 +213,8 @@ int simple_archiver_hash_map_insert(SDArchiverHashMap **hash_map, void *value, } } -void *simple_archiver_hash_map_get(SDArchiverHashMap *hash_map, void *key, - unsigned int key_size) { +void *simple_archiver_hash_map_get(const SDArchiverHashMap *hash_map, + const void *key, unsigned int key_size) { unsigned long long hash = simple_archiver_hash_map_internal_key_to_hash(key, key_size) % hash_map->buckets_size; diff --git a/src/data_structures/hash_map.h b/src/data_structures/hash_map.h index 898eff1..ae8b8ee 100644 --- a/src/data_structures/hash_map.h +++ b/src/data_structures/hash_map.h @@ -45,8 +45,8 @@ int simple_archiver_hash_map_insert(SDArchiverHashMap **hash_map, void *value, void (*key_cleanup_fn)(void *)); /// Returns NULL if not found. -void *simple_archiver_hash_map_get(SDArchiverHashMap *hash_map, void *key, - unsigned int key_size); +void *simple_archiver_hash_map_get(const SDArchiverHashMap *hash_map, + const void *key, unsigned int key_size); /// Returns zero on success. Returns one if more than one entry was removed. /// Otherwise returns non-zero and non-one value on error.