From ad54d804fef1e1eb646d8ea4bd7ce65363e94fa8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 13 Mar 2019 00:22:31 +0100 Subject: Fix bugs Fix hash map bug on rorder (invalid size). Fix string to int/float conversion in tokenizer. Add more ssa functions --- src/std/hash_map.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/std/hash_map.c') diff --git a/src/std/hash_map.c b/src/std/hash_map.c index 402c56d..61030da 100644 --- a/src/std/hash_map.c +++ b/src/std/hash_map.c @@ -116,7 +116,7 @@ static void hash_map_reorder_nodes(HashMap *self, usize end_index) { bucket_node = bucket_node_get_next(bucket_node); bucket_node_set_next(moved_node, new_bucket->start); new_bucket->start = moved_node; - /* Mark bucket node to be removed bucket by dechaining */ + /* Remove current from chain by chaining previous and next */ if(prev_bucket_node) bucket_node_set_next(prev_bucket_node, bucket_node); else @@ -134,13 +134,13 @@ static void hash_map_reorder_nodes(HashMap *self, usize end_index) { } static CHECK_RESULT int hash_map_increase_buckets(HashMap *self) { - usize prev_size; + usize prev_num_elements; usize bytes_to_append; - prev_size = buffer_get_size(&self->buckets, HashMapBucket); - bytes_to_append = prev_size * 1.5; + prev_num_elements = buffer_get_size(&self->buckets, HashMapBucket); + bytes_to_append = (usize)(prev_num_elements * 1.5) * sizeof(HashMapBucket); return_if_error(buffer_append(&self->buckets, NULL, bytes_to_append)); - am_memset(((HashMapBucket*)self->buckets.data) + prev_size, 0, bytes_to_append); - hash_map_reorder_nodes(self, prev_size); + am_memset(((HashMapBucket*)self->buckets.data) + prev_num_elements, 0, bytes_to_append); + hash_map_reorder_nodes(self, prev_num_elements); return 0; } -- cgit v1.2.3