| 2810 | } php_class_field_table_t; |
| 2811 | |
| 2812 | static 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 | |
| 2835 | static void add_field(php_class_fields_t *f, CBMArena *arena, const char *name, |
| 2836 | const CBMType *type) { |
no test coverage detected