ck_hash: decrease hash collisions and avoid growing initially
For regular hash tables, the hash needs to grow at 75%.
This condition will likely happen, and implies re-inserting
everything again.
Doubling the initial size avoids this inefficiency, and still retains
the ability to grow beyond the initial specified size.
@@ -150,6 +150,7 @@ ck_hash_table_t *ck_hash_table_init(size_t size)
ck_hash_table_t *table;
if ((table = malloc(sizeof(ck_hash_table_t))) == NULL)
return NULL;
+ size *= 2;
if ((table->entries = malloc(size * sizeof(ck_hash_entry_t))) == NULL) {
free(table);
return NULL;
