| 42 | }; |
| 43 | |
| 44 | CBMHashTable *cbm_ht_create(uint32_t initial_capacity) { |
| 45 | CBMHashTable *ht = (CBMHashTable *)calloc(CBM_ALLOC_ONE, sizeof(*ht)); |
| 46 | if (!ht) |
| 47 | return NULL; |
| 48 | cbm_vt_init(&ht->vt); |
| 49 | if (initial_capacity > 0) { |
| 50 | /* Reserve enough buckets for the requested entries. Verstable |
| 51 | * computes the minimum bucket count internally. */ |
| 52 | if (!cbm_vt_reserve(&ht->vt, (size_t)initial_capacity)) { |
| 53 | cbm_vt_cleanup(&ht->vt); |
| 54 | free(ht); |
| 55 | return NULL; |
| 56 | } |
| 57 | } |
| 58 | return ht; |
| 59 | } |
| 60 | |
| 61 | void cbm_ht_free(CBMHashTable *ht) { |
| 62 | if (!ht) |
no outgoing calls
no test coverage detected