From 8225f75cdc56f8efe61efa78237ce3d06f10d3a1 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sat, 4 Jan 2025 00:26:39 +0100 Subject: take initial capacity in init function --- lib/hashtable.c | 3 +-- lib/hashtable.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/hashtable.c b/lib/hashtable.c index 00e05d7..2015b9c 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -30,10 +30,9 @@ static int hash(char* key, size_t bucket_len) { return sum % bucket_len; } -HashTable hashtable_init() { +HashTable hashtable_init(size_t capacity) { HashTableImpl* ht = (HashTableImpl*) malloc(sizeof(HashTableImpl)); - int capacity = 8; ht->buckets = (HashTableBucket*) calloc(sizeof(HashTableBucket), capacity); ht->capacity = capacity; diff --git a/lib/hashtable.h b/lib/hashtable.h index 5bdcb08..3f4be0e 100644 --- a/lib/hashtable.h +++ b/lib/hashtable.h @@ -3,7 +3,7 @@ void typedef *HashTable; -HashTable hashtable_init(); +HashTable hashtable_init(size_t); int hashtable_deinit(HashTable*); -- cgit 1.4.1