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

Function fields_for

internal/cbm/lsp/php_lsp.c:3109–3130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3107} php_class_field_table_t;
3108
3109static php_class_fields_t *fields_for(php_class_field_table_t *tab, const char *class_qn,
3110 CBMArena *arena) {
3111 for (int i = 0; i < tab->count; i++) {
3112 if (strcmp(tab->items[i].class_qn, class_qn) == 0)
3113 return &tab->items[i];
3114 }
3115 if (tab->count >= tab->cap) {
3116 int new_cap = tab->cap ? tab->cap * 2 : 16;
3117 php_class_fields_t *next =
3118 (php_class_fields_t *)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(*next));
3119 if (!next)
3120 return NULL;
3121 for (int i = 0; i < tab->count; i++)
3122 next[i] = tab->items[i];
3123 tab->items = next;
3124 tab->cap = new_cap;
3125 }
3126 php_class_fields_t *f = &tab->items[tab->count++];
3127 memset(f, 0, sizeof(*f));
3128 f->class_qn = cbm_arena_strdup(arena, class_qn);
3129 return f;
3130}
3131
3132static void add_field(php_class_fields_t *f, CBMArena *arena, const char *name,
3133 const CBMType *type) {

Callers 1

process_class_for_fieldsFunction · 0.85

Calls 2

cbm_arena_allocFunction · 0.50
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected