Make sure flist can hold at least flist->used + extra entries. */
| 300 | |
| 301 | /* Make sure flist can hold at least flist->used + extra entries. */ |
| 302 | static void flist_expand(struct file_list *flist, int extra) |
| 303 | { |
| 304 | struct file_struct **new_ptr; |
| 305 | |
| 306 | if (flist->used + extra <= flist->malloced) |
| 307 | return; |
| 308 | |
| 309 | if (flist->malloced < FLIST_START) |
| 310 | flist->malloced = FLIST_START; |
| 311 | else if (flist->malloced >= FLIST_LINEAR) |
| 312 | flist->malloced += FLIST_LINEAR; |
| 313 | else if (flist->malloced < FLIST_START_LARGE/16) |
| 314 | flist->malloced *= 4; |
| 315 | else |
| 316 | flist->malloced *= 2; |
| 317 | |
| 318 | /* In case count jumped or we are starting the list |
| 319 | * with a known size just set it. */ |
| 320 | if (flist->malloced < flist->used + extra) |
| 321 | flist->malloced = flist->used + extra; |
| 322 | |
| 323 | new_ptr = realloc_array(flist->files, struct file_struct *, flist->malloced); |
| 324 | |
| 325 | if (DEBUG_GTE(FLIST, 1) && flist->files) { |
| 326 | rprintf(FCLIENT, "[%s] expand file_list pointer array to %s bytes, did%s move\n", |
| 327 | who_am_i(), |
| 328 | big_num(sizeof flist->files[0] * flist->malloced), |
| 329 | (new_ptr == flist->files) ? " not" : ""); |
| 330 | } |
| 331 | |
| 332 | flist->files = new_ptr; |
| 333 | } |
| 334 | |
| 335 | static void flist_done_allocating(struct file_list *flist) |
| 336 | { |
no test coverage detected