diff options
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -3009,8 +3009,8 @@ int remove_path(const char *name) } /* - * Frees memory within dir which was allocated for exclude lists and - * the exclude_stack. Does not free dir itself. + * Frees memory within dir which was allocated, and resets fields for further + * use. Does not free dir itself. */ void clear_directory(struct dir_struct *dir) { @@ -3030,6 +3030,13 @@ void clear_directory(struct dir_struct *dir) free(group->pl); } + for (i = 0; i < dir->ignored_nr; i++) + free(dir->ignored[i]); + for (i = 0; i < dir->nr; i++) + free(dir->entries[i]); + free(dir->ignored); + free(dir->entries); + stk = dir->exclude_stack; while (stk) { struct exclude_stack *prev = stk->prev; @@ -3037,6 +3044,8 @@ void clear_directory(struct dir_struct *dir) stk = prev; } strbuf_release(&dir->basebuf); + + memset(&dir, 0, sizeof(*dir)); } struct ondisk_untracked_cache { |