| 3107 | } php_class_field_table_t; |
| 3108 | |
| 3109 | static 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 | |
| 3132 | static void add_field(php_class_fields_t *f, CBMArena *arena, const char *name, |
| 3133 | const CBMType *type) { |
no test coverage detected