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

Function cs_fields_add_debug

internal/cbm/lsp/cs_lsp.c:3186–3216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3184}
3185
3186static void cs_fields_add_debug(CBMArena *arena, cs_fields_t *f, const char *name,
3187 const CBMType *type, bool debug) {
3188 (void)debug;
3189 if (!f || !name)
3190 return;
3191 /* Dedupe. */
3192 for (int i = 0; i < f->count; i++) {
3193 if (strcmp(f->field_names[i], name) == 0)
3194 return;
3195 }
3196 if (f->count + 2 >= f->cap) {
3197 int new_cap = f->cap * 2;
3198 const char **nn = (const char **)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(*nn));
3199 const CBMType **nt =
3200 (const CBMType **)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(*nt));
3201 if (!nn || !nt)
3202 return;
3203 for (int i = 0; i < f->count; i++) {
3204 nn[i] = f->field_names[i];
3205 nt[i] = f->field_types[i];
3206 }
3207 f->field_names = nn;
3208 f->field_types = nt;
3209 f->cap = new_cap;
3210 }
3211 f->field_names[f->count] = cbm_arena_strdup(arena, name);
3212 f->field_types[f->count] = type ? type : cbm_type_unknown();
3213 f->count++;
3214 f->field_names[f->count] = NULL;
3215 f->field_types[f->count] = NULL;
3216}
3217
3218static void cs_collect_class_fields(CSLSPContext *ctx, CBMTypeRegistry *reg, TSNode root,
3219 cs_fields_table_t *tab) {

Callers 2

cs_fields_addFunction · 0.85
cs_collect_class_fieldsFunction · 0.85

Calls 3

cbm_type_unknownFunction · 0.85
cbm_arena_allocFunction · 0.50
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected