]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
Merge branch 'jc/diffcore-rotate'
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index 71e4738548421a6137546f0c693a6a95464b89b8..6956f5e335c235d0a1a2ea6d8b7b8e7b7678deda 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -6355,6 +6355,32 @@ static void diff_flush_patch_all_file_pairs(struct diff_options *o)
        }
 }
 
+static void diff_free_file(struct diff_options *options)
+{
+       if (options->close_file)
+               fclose(options->file);
+}
+
+static void diff_free_ignore_regex(struct diff_options *options)
+{
+       int i;
+
+       for (i = 0; i < options->ignore_regex_nr; i++) {
+               regfree(options->ignore_regex[i]);
+               free(options->ignore_regex[i]);
+       }
+       free(options->ignore_regex);
+}
+
+void diff_free(struct diff_options *options)
+{
+       if (options->no_free)
+               return;
+
+       diff_free_file(options);
+       diff_free_ignore_regex(options);
+}
+
 void diff_flush(struct diff_options *options)
 {
        struct diff_queue_struct *q = &diff_queued_diff;
@@ -6418,8 +6444,7 @@ void diff_flush(struct diff_options *options)
                 * options->file to /dev/null should be safe, because we
                 * aren't supposed to produce any output anyway.
                 */
-               if (options->close_file)
-                       fclose(options->file);
+               diff_free_file(options);
                options->file = xfopen("/dev/null", "w");
                options->close_file = 1;
                options->color_moved = 0;
@@ -6452,8 +6477,7 @@ void diff_flush(struct diff_options *options)
 free_queue:
        free(q->queue);
        DIFF_QUEUE_CLEAR(q);
-       if (options->close_file)
-               fclose(options->file);
+       diff_free(options);
 
        /*
         * Report the content-level differences with HAS_CHANGES;