From e99e391ffab69749d0006ab30b922810c47a6a42 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 25 Sep 2024 10:39:27 +0200 Subject: [PATCH] chore: documentation and readability of hash_map.c --- hash_map.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hash_map.c b/hash_map.c index a4aa454..bad9f40 100644 --- a/hash_map.c +++ b/hash_map.c @@ -33,9 +33,9 @@ void *hash_map_get_raw(HashMap *self, void *key) { void hash_map_insert(HashMap *self, void *key, void *value) { uintptr_t hash = self->hasher(key); // stage key-value-pair data - char data[sizeof(uintptr_t) + self->key_size + self->value_size]; + char data[self->buckets[0].element_size]; memcpy(data, &hash, sizeof(uintptr_t)); // copy key hash into start of data - memcpy(data + sizeof(uintptr_t), key, self->key_size); + memcpy(data + sizeof(uintptr_t), key, self->key_size); // copy key after hash memcpy(data + sizeof(uintptr_t) + self->key_size, value, self->value_size); // copy value into end of data // insert staged data into list list_add(self->buckets + (hash % CUTES_HASH_MAP_BUCKETS), data);