Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/grep.c b/grep.c
index 0690ed9b89..cee44a78d0 100644
--- a/grep.c
+++ b/grep.c
@@ -815,11 +815,11 @@ static void free_pattern_expr(struct grep_expr *x)
free(x);
}
-void free_grep_patterns(struct grep_opt *opt)
+static void free_grep_pat(struct grep_pat *pattern)
{
struct grep_pat *p, *n;
- for (p = opt->pattern_list; p; p = n) {
+ for (p = pattern; p; p = n) {
n = p->next;
switch (p->token) {
case GREP_PATTERN: /* atom */
@@ -836,10 +836,15 @@ void free_grep_patterns(struct grep_opt *opt)
}
free(p);
}
+}
- if (!opt->pattern_expression)
- return;
- free_pattern_expr(opt->pattern_expression);
+void free_grep_patterns(struct grep_opt *opt)
+{
+ free_grep_pat(opt->pattern_list);
+ free_grep_pat(opt->header_list);
+
+ if (opt->pattern_expression)
+ free_pattern_expr(opt->pattern_expression);
}
static const char *end_of_line(const char *cp, unsigned long *left)