From 892388c2183faaa145caa5bde64921f57fd2dfeb Mon Sep 17 00:00:00 2001 From: Mineplay Date: Fri, 23 May 2025 17:35:50 -0500 Subject: [PATCH] refactor(hash table): added const to some function parameters --- Include/Fledasty/Core/HashTable.h | 4 ++-- Src/Core/HashTable.c | 2 +- Tests/Main.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Include/Fledasty/Core/HashTable.h b/Include/Fledasty/Core/HashTable.h index e1d0b30..ab26d1e 100644 --- a/Include/Fledasty/Core/HashTable.h +++ b/Include/Fledasty/Core/HashTable.h @@ -40,10 +40,10 @@ typedef struct { size_t key_byte_size, value_byte_size; FledastyDynamicArray *Table; - size_t (*hash_function)(void *key); + size_t (*hash_function)(const void *key); } FledastyHashTable; -FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, size_t key_byte_size, size_t value_byte_size, size_t (*hash_function)(void *key)); +FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, const size_t key_byte_size, const size_t value_byte_size, size_t (*hash_function)(const void *key)); FledastyError fledasty_hash_table_destroy(FledastyHashTable *current_hash_table); FledastyError fledasty_hash_table_insert(FledastyHashTable *current_hash_table, void *key, void *value); diff --git a/Src/Core/HashTable.c b/Src/Core/HashTable.c index 8e92a31..aacf83a 100644 --- a/Src/Core/HashTable.c +++ b/Src/Core/HashTable.c @@ -28,7 +28,7 @@ static const int FLEDASTY_HASH_TABLE_SIZE_THRESHOLD = 75; -FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, size_t key_byte_size, size_t value_byte_size, size_t (*hash_function)(void *key)) { +FledastyError fledasty_hash_table_initialize(FledastyHashTable *new_hash_table, const size_t key_byte_size, const size_t value_byte_size, size_t (*hash_function)(const void *key)) { if (new_hash_table == NULL || hash_function == NULL) { return FLEDASTY_ERROR_INVALID_POINTER; } diff --git a/Tests/Main.c b/Tests/Main.c index fba8285..4ce0f77 100644 --- a/Tests/Main.c +++ b/Tests/Main.c @@ -29,7 +29,7 @@ #include #include -static inline size_t integer_hash_function(void *key) { return *(size_t*)key; } +static inline size_t integer_hash_function(const void *key) { return *(size_t*)key; } int main() { FledastyQueue test_queue;