MCPcopy Create free account
hub / github.com/git/git / dir_clear

Function dir_clear

dir.c:3546–3581  ·  view source on GitHub ↗

* Frees memory within dir which was allocated, and resets fields for further * use. Does not free dir itself. */

Source from the content-addressed store, hash-verified

3544 * use. Does not free dir itself.
3545 */
3546void 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
3583struct ondisk_untracked_cache {
3584 struct stat_data info_exclude_stat;

Callers 12

unpack_treesFunction · 0.85
get_untracked_filesFunction · 0.85
grep_directoryFunction · 0.85
get_untracked_filesFunction · 0.85
cmd_ls_filesFunction · 0.85
cmd_addFunction · 0.85
filter_by_patterns_cmdFunction · 0.85
cmd_cleanFunction · 0.85
cmd_check_ignoreFunction · 0.85

Calls 2

clear_pattern_listFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected