From 03bebea4b27954347f2633f0867ae61a5be6ded4 Mon Sep 17 00:00:00 2001 From: Timerix Date: Thu, 24 Jul 2025 18:08:09 +0300 Subject: [PATCH] renamed sosme HashMap methods --- include/tlibc/collections/HashMap.h | 5 ++--- src/collections/HashMap.c | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/tlibc/collections/HashMap.h b/include/tlibc/collections/HashMap.h index 1c00071..a7f0514 100755 --- a/include/tlibc/collections/HashMap.h +++ b/include/tlibc/collections/HashMap.h @@ -26,9 +26,8 @@ typedef struct HashMap_ { u16 height_n; } HashMap_; -//TODO: standartize constructor function names across tlibc -#define HashMap_create(PTR, T, VALUE_DESTRUCTOR) HashMap_create_size(PTR, sizeof(T), VALUE_DESTRUCTOR) -void HashMap_create_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor)); +#define HashMap_construct(PTR, T, VALUE_DESTRUCTOR) HashMap_construct_size(PTR, sizeof(T), VALUE_DESTRUCTOR) +void HashMap_construct_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor)); void HashMap_destroy(HashMap_* ptr); void* NULLABLE(HashMap_tryGetPtr)(HashMap_* ptr, str key); bool HashMap_tryPush(HashMap_* ptr, str key, void* value_ptr); diff --git a/src/collections/HashMap.c b/src/collections/HashMap.c index 2d8f9fb..d91d1ea 100755 --- a/src/collections/HashMap.c +++ b/src/collections/HashMap.c @@ -13,10 +13,11 @@ static const Array(u32) __HashMap_heights = ARRAY(u32, { }); -void HashMap_create_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor)){ +void HashMap_construct_size(HashMap_* ptr, u32 value_t_size, FreeFunction NULLABLE(value_destructor)){ ptr->value_t_size = value_t_size; ptr->value_destructor = value_destructor; ptr->height_n = 0; + //TODO: make first height == 0 and call malloc later ptr->height = ((u32*)__HashMap_heights.data)[0]; u32 alloc_size = ptr->height * sizeof(HashMapBucket); ptr->table = (HashMapBucket*)malloc(alloc_size);