- struct htable *ht = malloc(sizeof(struct htable));
- if (ht) {
- ht->bits = HTABLE_BASE_BITS;
- ht->rehash = rehash;
- ht->priv = priv;
- ht->elems = 0;
- ht->deleted = 0;
- ht->max = ((size_t)1 << ht->bits) * 3 / 4;
- ht->max_with_deleted = ((size_t)1 << ht->bits) * 9 / 10;
- /* This guarantees we enter update_common first add. */
- ht->common_mask = -1;
- ht->common_bits = 0;
- ht->perfect_bit = 0;
- ht->table = calloc(1 << ht->bits, sizeof(uintptr_t));
- if (!ht->table) {
- free(ht);
- ht = NULL;
- }
- }
- return ht;
+ struct htable empty = HTABLE_INITIALIZER(empty, NULL, NULL);
+ *ht = empty;
+ ht->rehash = rehash;
+ ht->priv = priv;
+ ht->table = &ht->perfect_bit;