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

Function fields_for

internal/cbm/lsp/php_lsp.c:3034–3055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3032} php_class_field_table_t;
3033
3034static php_class_fields_t *fields_for(php_class_field_table_t *tab, const char *class_qn,
3035 CBMArena *arena) {
3036 for (int i = 0; i < tab->count; i++) {
3037 if (strcmp(tab->items[i].class_qn, class_qn) == 0)
3038 return &tab->items[i];
3039 }
3040 if (tab->count >= tab->cap) {
3041 int new_cap = tab->cap ? tab->cap * 2 : 16;
3042 php_class_fields_t *next =
3043 (php_class_fields_t *)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(*next));
3044 if (!next)
3045 return NULL;
3046 for (int i = 0; i < tab->count; i++)
3047 next[i] = tab->items[i];
3048 tab->items = next;
3049 tab->cap = new_cap;
3050 }
3051 php_class_fields_t *f = &tab->items[tab->count++];
3052 memset(f, 0, sizeof(*f));
3053 f->class_qn = cbm_arena_strdup(arena, class_qn);
3054 return f;
3055}
3056
3057static void add_field(php_class_fields_t *f, CBMArena *arena, const char *name,
3058 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