diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-04 00:26:39 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-04 00:26:39 +0100 |
commit | 8225f75cdc56f8efe61efa78237ce3d06f10d3a1 (patch) | |
tree | 9ffd30c56c53a6cae9af6dbb09ce2e493c4400c2 /lib | |
parent | another test (diff) | |
download | c-hashtable-8225f75cdc56f8efe61efa78237ce3d06f10d3a1.tar.gz c-hashtable-8225f75cdc56f8efe61efa78237ce3d06f10d3a1.tar.bz2 c-hashtable-8225f75cdc56f8efe61efa78237ce3d06f10d3a1.zip |
take initial capacity in init function
Diffstat (limited to '')
-rw-r--r-- | lib/hashtable.c | 3 | ||||
-rw-r--r-- | lib/hashtable.h | 2 |
2 files changed, 2 insertions, 3 deletions
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*); |