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);