| 91 | } |
| 92 | |
| 93 | static CBMHashTable *ht_create_at(cbm_mem_class_t cls, uint32_t initial_capacity, void *site) { |
| 94 | CBMHashTable *ht = (CBMHashTable *)cbm_calloc(cls, sizeof(*ht)); |
| 95 | if (!ht) |
| 96 | return NULL; |
| 97 | ht->waste_site = site; |
| 98 | cbm_vt_init(&ht->vt, cls); |
| 99 | if (initial_capacity > 0) { |
| 100 | /* Reserve enough buckets for the requested entries. Verstable |
| 101 | * computes the minimum bucket count internally. */ |
| 102 | if (!cbm_vt_reserve(&ht->vt, (size_t)initial_capacity)) { |
| 103 | cbm_vt_cleanup(&ht->vt); |
| 104 | cbm_free(cls, ht); |
| 105 | return NULL; |
| 106 | } |
| 107 | } |
| 108 | return ht; |
| 109 | } |
| 110 | |
| 111 | void cbm_ht_free(CBMHashTable *ht) { |
| 112 | if (!ht) |
no test coverage detected