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

Function intern_resize

src/foundation/str_intern.c:72–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72static void intern_resize(CBMInternPool *p) {
73 uint32_t new_cap = p->capacity * PAIR_LEN;
74 uint32_t new_mask = new_cap - SKIP_ONE;
75 InternEntry *new_buckets = (InternEntry *)calloc(new_cap, sizeof(InternEntry));
76 if (!new_buckets) {
77 return;
78 }
79
80 for (uint32_t i = 0; i < p->capacity; i++) {
81 const InternEntry *e = &p->buckets[i];
82 if (!e->str) {
83 continue;
84 }
85 uint32_t idx = e->hash & new_mask;
86 while (new_buckets[idx].str) {
87 idx = (idx + SKIP_ONE) & new_mask;
88 }
89 new_buckets[idx] = *e;
90 }
91
92 free(p->buckets);
93 p->buckets = new_buckets;
94 p->capacity = new_cap;
95 p->mask = new_mask;
96}
97
98const char *cbm_intern_n(CBMInternPool *pool, const char *s, size_t len) {
99 if (!pool || !s) {

Callers 1

cbm_intern_nFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected