* Frees memory within dir which was allocated, and resets fields for further * use. Does not free dir itself. */
| 3544 | * use. Does not free dir itself. |
| 3545 | */ |
| 3546 | void dir_clear(struct dir_struct *dir) |
| 3547 | { |
| 3548 | int i, j; |
| 3549 | struct exclude_list_group *group; |
| 3550 | struct pattern_list *pl; |
| 3551 | struct exclude_stack *stk; |
| 3552 | struct dir_struct new = DIR_INIT; |
| 3553 | |
| 3554 | for (i = EXC_CMDL; i <= EXC_FILE; i++) { |
| 3555 | group = &dir->internal.exclude_list_group[i]; |
| 3556 | for (j = 0; j < group->nr; j++) { |
| 3557 | pl = &group->pl[j]; |
| 3558 | if (i == EXC_DIRS) |
| 3559 | free((char *)pl->src); |
| 3560 | clear_pattern_list(pl); |
| 3561 | } |
| 3562 | free(group->pl); |
| 3563 | } |
| 3564 | |
| 3565 | for (i = 0; i < dir->ignored_nr; i++) |
| 3566 | free(dir->ignored[i]); |
| 3567 | for (i = 0; i < dir->nr; i++) |
| 3568 | free(dir->entries[i]); |
| 3569 | free(dir->ignored); |
| 3570 | free(dir->entries); |
| 3571 | |
| 3572 | stk = dir->internal.exclude_stack; |
| 3573 | while (stk) { |
| 3574 | struct exclude_stack *prev = stk->prev; |
| 3575 | free(stk); |
| 3576 | stk = prev; |
| 3577 | } |
| 3578 | strbuf_release(&dir->internal.basebuf); |
| 3579 | |
| 3580 | memcpy(dir, &new, sizeof(*dir)); |
| 3581 | } |
| 3582 | |
| 3583 | struct ondisk_untracked_cache { |
| 3584 | struct stat_data info_exclude_stat; |
no test coverage detected