summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-04 00:26:39 +0100
committerBaitinq <manuelpalenzuelamerino@gmail.com>2025-01-04 00:26:39 +0100
commit8225f75cdc56f8efe61efa78237ce3d06f10d3a1 (patch)
tree9ffd30c56c53a6cae9af6dbb09ce2e493c4400c2 /lib
parentanother test (diff)
downloadc-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.c3
-rw-r--r--lib/hashtable.h2
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*);