dir.c: clean the entire struct in clear_exclude_list()
[gitweb.git] / dir.c
diff --git a/dir.c b/dir.c
index bd274a73f1faaee40bce34024ef17bfd44fbcad7..736ff2ac1127a5578c5dc2e915b3e1cf5b203bfb 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -501,9 +501,7 @@ void clear_exclude_list(struct exclude_list *el)
        free(el->excludes);
        free(el->filebuf);
 
-       el->nr = 0;
-       el->excludes = NULL;
-       el->filebuf = NULL;
+       memset(el, 0, sizeof(*el));
 }
 
 static void trim_trailing_spaces(char *buf)
@@ -826,9 +824,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
        current = stk ? stk->baselen : -1;
        strbuf_setlen(&dir->basebuf, current < 0 ? 0 : current);
        while (current < baselen) {
-               struct exclude_stack *stk = xcalloc(1, sizeof(*stk));
                const char *cp;
 
+               stk = xcalloc(1, sizeof(*stk));
                if (current < 0) {
                        cp = base;
                        current = 0;