aboutsummaryrefslogtreecommitdiff
path: root/src/std
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-03-13 00:22:31 +0100
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commitad54d804fef1e1eb646d8ea4bd7ce65363e94fa8 (patch)
tree41c2d7d9979c98bdd508929a01949ba2f02c679b /src/std
parent2d2c31cc18aa9af2cdf26fa462edf7a164d45328 (diff)
Fix bugs
Fix hash map bug on rorder (invalid size). Fix string to int/float conversion in tokenizer. Add more ssa functions
Diffstat (limited to 'src/std')
-rw-r--r--src/std/hash_map.c12
1 files changed, 6 insertions, 6 deletions
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;
}