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

Function cs_fields_get

internal/cbm/lsp/cs_lsp.c:2360–2383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2358} cs_fields_table_t;
2359
2360static cs_fields_t *cs_fields_get(CBMArena *arena, cs_fields_table_t *tab,
2361 const char *class_qn) {
2362 for (int i = 0; i < tab->count; i++) {
2363 if (strcmp(tab->items[i].class_qn, class_qn) == 0) return &tab->items[i];
2364 }
2365 if (tab->count + 1 >= tab->cap) {
2366 int new_cap = tab->cap ? tab->cap * 2 : 8;
2367 cs_fields_t *ne =
2368 (cs_fields_t *)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(*ne));
2369 if (!ne) return NULL;
2370 for (int i = 0; i < tab->count; i++) ne[i] = tab->items[i];
2371 tab->items = ne;
2372 tab->cap = new_cap;
2373 }
2374 cs_fields_t *slot = &tab->items[tab->count++];
2375 memset(slot, 0, sizeof(*slot));
2376 slot->class_qn = class_qn;
2377 slot->cap = 8;
2378 slot->field_names =
2379 (const char **)cbm_arena_alloc(arena, (size_t)slot->cap * sizeof(*slot->field_names));
2380 slot->field_types =
2381 (const CBMType **)cbm_arena_alloc(arena, (size_t)slot->cap * sizeof(*slot->field_types));
2382 return slot;
2383}
2384
2385static void cs_fields_add_debug(CBMArena *arena, cs_fields_t *f, const char *name,
2386 const CBMType *type, bool debug);

Callers 1

cs_collect_class_fieldsFunction · 0.85

Calls 1

cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected