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

Function gm_intern

src/store/graph_mem.c:240–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240static int gm_intern(cbm_graph_mem_t *g, const unsigned char *text, size_t len, int *last) {
241 if (*last >= 0 && g->type_len[*last] == len && memcmp(g->types[*last], text, len) == 0) {
242 return *last;
243 }
244 for (int i = 0; i < g->type_count; i++) {
245 if (g->type_len[i] == len && memcmp(g->types[i], text, len) == 0) {
246 *last = i;
247 return i;
248 }
249 }
250 if (g->type_count >= GM_MAX_TYPES) {
251 return -1;
252 }
253 char *copy = gm_alloc(len + 1);
254 if (!copy) {
255 return -1;
256 }
257 memcpy(copy, text, len);
258 copy[len] = '\0';
259 g->types[g->type_count] = copy;
260 g->type_len[g->type_count] = len;
261 *last = g->type_count;
262 return g->type_count++;
263}
264
265static bool gm_grow_u32(uint32_t **arr, size_t *cap, size_t need) {
266 if (need <= *cap) {

Callers 1

gm_scan_rowFunction · 0.85

Calls 1

gm_allocFunction · 0.85

Tested by

no test coverage detected