| 61 | } |
| 62 | |
| 63 | CBMHashTable *cbm_ht_create_in(cbm_mem_class_t cls, uint32_t initial_capacity) { |
| 64 | CBMHashTable *ht = (CBMHashTable *)cbm_calloc(cls, sizeof(*ht)); |
| 65 | if (!ht) |
| 66 | return NULL; |
| 67 | cbm_vt_init(&ht->vt, cls); |
| 68 | if (initial_capacity > 0) { |
| 69 | /* Reserve enough buckets for the requested entries. Verstable |
| 70 | * computes the minimum bucket count internally. */ |
| 71 | if (!cbm_vt_reserve(&ht->vt, (size_t)initial_capacity)) { |
| 72 | cbm_vt_cleanup(&ht->vt); |
| 73 | cbm_free(cls, ht); |
| 74 | return NULL; |
| 75 | } |
| 76 | } |
| 77 | return ht; |
| 78 | } |
| 79 | |
| 80 | void cbm_ht_free(CBMHashTable *ht) { |
| 81 | if (!ht) |
no test coverage detected