Skip to content

Commit

Permalink
dir.c: add free_excludes()
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Nov 29, 2010
1 parent 2977ffb commit 0fd0e24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
12 changes: 12 additions & 0 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ static void *read_skip_worktree_file_from_index(const char *path, size_t *size)
return data;
}

void free_excludes(struct exclude_list *el)
{
int i;

for (i = 0; i < el->nr; i++)
free(el->excludes[i]);
free(el->excludes);

el->nr = 0;
el->excludes = NULL;
}

int add_excludes_from_file_to_list(const char *fname,
const char *base,
int baselen,
Expand Down
1 change: 1 addition & 0 deletions dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern int add_excludes_from_file_to_list(const char *fname, const char *base, i
extern void add_excludes_from_file(struct dir_struct *, const char *fname);
extern void add_exclude(const char *string, const char *base,
int baselen, struct exclude_list *which);
extern void free_excludes(struct exclude_list *el);
extern int file_exists(const char *);

extern char *get_relative_cwd(char *buffer, int size, const char *dir);
Expand Down
6 changes: 1 addition & 5 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
*o->dst_index = o->result;

done:
for (i = 0;i < el.nr;i++)
free(el.excludes[i]);
if (el.excludes)
free(el.excludes);

free_excludes(&el);
return ret;

return_failed:
Expand Down

0 comments on commit 0fd0e24

Please sign in to comment.