MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_ht_create_in

Function cbm_ht_create_in

src/foundation/hash_table.c:63–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63CBMHashTable *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
80void cbm_ht_free(CBMHashTable *ht) {
81 if (!ht)

Callers 3

cbm_gbuf_newFunction · 0.85
cbm_ht_createFunction · 0.85

Calls 2

cbm_callocFunction · 0.85
cbm_freeFunction · 0.85

Tested by

no test coverage detected