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

Function fields_for

internal/cbm/lsp/php_lsp.c:2812–2833  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2810} php_class_field_table_t;
2811
2812static php_class_fields_t *fields_for(php_class_field_table_t *tab, const char *class_qn,
2813 CBMArena *arena) {
2814 for (int i = 0; i < tab->count; i++) {
2815 if (strcmp(tab->items[i].class_qn, class_qn) == 0)
2816 return &tab->items[i];
2817 }
2818 if (tab->count >= tab->cap) {
2819 int new_cap = tab->cap ? tab->cap * 2 : 16;
2820 php_class_fields_t *next =
2821 (php_class_fields_t *)cbm_arena_alloc(arena, (size_t)new_cap * sizeof(*next));
2822 if (!next)
2823 return NULL;
2824 for (int i = 0; i < tab->count; i++)
2825 next[i] = tab->items[i];
2826 tab->items = next;
2827 tab->cap = new_cap;
2828 }
2829 php_class_fields_t *f = &tab->items[tab->count++];
2830 memset(f, 0, sizeof(*f));
2831 f->class_qn = cbm_arena_strdup(arena, class_qn);
2832 return f;
2833}
2834
2835static void add_field(php_class_fields_t *f, CBMArena *arena, const char *name,
2836 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