| 143 | } |
| 144 | |
| 145 | static cbm_diff_file_t *df_add_file(cbm_diff_t *d, const char *path) { |
| 146 | if (d->file_count == d->file_cap) { |
| 147 | int cap = d->file_cap > 0 ? d->file_cap * DF_GROWTH : DF_FIRST_CAP; |
| 148 | cbm_diff_file_t *grown = cbm_arena_alloc(&d->arena, (size_t)cap * sizeof(*grown)); |
| 149 | if (!grown) { |
| 150 | return NULL; |
| 151 | } |
| 152 | if (d->file_count > 0) { |
| 153 | memcpy(grown, d->files, (size_t)d->file_count * sizeof(*grown)); |
| 154 | } |
| 155 | d->files = grown; |
| 156 | d->file_cap = cap; |
| 157 | } |
| 158 | cbm_diff_file_t *file = &d->files[d->file_count++]; |
| 159 | *file = (cbm_diff_file_t){.path = path}; |
| 160 | return file; |
| 161 | } |
| 162 | |
| 163 | /* The hunks of the file being read; handed to the file when it ends. */ |
| 164 | typedef struct { |
no test coverage detected