aboutsummaryrefslogtreecommitdiff
path: root/src/std
diff options
context:
space:
mode:
Diffstat (limited to 'src/std')
-rw-r--r--src/std/hash_map.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/std/hash_map.c b/src/std/hash_map.c
index a649a95..402c56d 100644
--- a/src/std/hash_map.c
+++ b/src/std/hash_map.c
@@ -42,10 +42,10 @@ static BufferView bucket_node_get_key(HashMapBucketNode *self) {
return key;
}
-static void bucket_node_set_value(HashMapBucketNode *self, void *value, usize type_size) {
+static void bucket_node_set_value(HashMapBucketNode *self, void *value, usize value_type_size) {
u32 key_size;
am_memcpy(&key_size, (char*)self + sizeof(HashMapBucketNode*), sizeof(key_size));
- am_memcpy((char*)self + sizeof(HashMapBucketNode*) + sizeof(u32) + key_size, value, type_size);
+ am_memcpy((char*)self + sizeof(HashMapBucketNode*) + sizeof(u32) + key_size, value, value_type_size);
}
static void* bucket_node_get_value(HashMapBucketNode *self) {
@@ -56,12 +56,12 @@ static void* bucket_node_get_value(HashMapBucketNode *self) {
return value;
}
-int hash_map_init(HashMap *self, ScopedAllocator *allocator, usize type_size,
+int hash_map_init(HashMap *self, ScopedAllocator *allocator, usize value_type_size,
HashMapCompare compare_func, HashMapHash hash_func) {
assert(compare_func);
assert(hash_func);
self->allocator = allocator;
- self->type_size = type_size;
+ self->value_type_size = value_type_size;
self->num_elements = 0;
self->compare_func = compare_func;
self->hash_func = hash_func;
@@ -75,11 +75,11 @@ int hash_map_init(HashMap *self, ScopedAllocator *allocator, usize type_size,
static CHECK_RESULT int hash_map_bucket_add(HashMap *self, HashMapBucket *bucket, BufferView key, void *value) {
HashMapBucketNode *new_bucket_node;
return_if_error(scoped_allocator_alloc(self->allocator,
- sizeof(HashMapBucketNode*) + sizeof(u32) + key.size + self->type_size,
+ sizeof(HashMapBucketNode*) + sizeof(u32) + key.size + self->value_type_size,
(void**)&new_bucket_node));
bucket_node_set_next(new_bucket_node, bucket->start);
bucket_node_set_key(new_bucket_node, key);
- bucket_node_set_value(new_bucket_node, value, self->type_size);
+ bucket_node_set_value(new_bucket_node, value, self->value_type_size);
bucket->start = new_bucket_node;
return 0;
}
@@ -176,7 +176,7 @@ bool hash_map_get(HashMap *self, BufferView key, void *value) {
BufferView bucket_key;
bucket_key = bucket_node_get_key(bucket_node);
if(self->compare_func(&key, &bucket_key) == 0) {
- am_memcpy(value, bucket_node_get_value(bucket_node), self->type_size);
+ am_memcpy(value, bucket_node_get_value(bucket_node), self->value_type_size);
return bool_true;
}
}