summaryrefslogtreecommitdiff
path: root/diff.h
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-02-22 16:12:43 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-02-22 16:12:43 -0800
commit45df6c4d756df25d04f82f4803923baaf0c12a33 (patch)
treeb30ad9c606be7977d5dd5df0f35d91b1450aea55 /diff.h
parentMerge branch 'ab/pager-exit-log' (diff)
parentdiff: plug memory leak from regcomp() on {log,diff} -I (diff)
downloadtgif-45df6c4d756df25d04f82f4803923baaf0c12a33.tar.xz
Merge branch 'ab/diff-deferred-free'
A small memleak in "diff -I<regexp>" has been corrected. * ab/diff-deferred-free: diff: plug memory leak from regcomp() on {log,diff} -I diff: add an API for deferred freeing
Diffstat (limited to 'diff.h')
-rw-r--r--diff.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/diff.h b/diff.h
index 2ff2b1c7f2..527fb56d85 100644
--- a/diff.h
+++ b/diff.h
@@ -49,7 +49,17 @@
* - Once you finish feeding the pairs of files, call `diffcore_std()`.
* This will tell the diffcore library to go ahead and do its work.
*
- * - Calling `diff_flush()` will produce the output.
+ * - Calling `diff_flush()` will produce the output, it will call
+ * `diff_free()` to free any resources, e.g. those allocated in
+ * `diff_opt_parse()`.
+ *
+ * - Set `.no_free = 1` before calling `diff_flush()` to defer the
+ * freeing of allocated memory in diff_options. This is useful when
+ * `diff_flush()` is being called in a loop, rather than as a
+ * one-off. When setting `.no_free = 1` you must ensure that
+ * `diff_free()` is called at the end, either by flipping the flag
+ * before the last `diff_flush()` call, or by flipping it before
+ * calling `diff_free()` yourself.
*/
struct combine_diff_path;
@@ -365,6 +375,8 @@ struct diff_options {
struct repository *repo;
struct option *parseopts;
+
+ int no_free;
};
unsigned diff_filter_bit(char status);
@@ -559,6 +571,7 @@ void diffcore_fix_diff_index(void);
int diff_queue_is_empty(void);
void diff_flush(struct diff_options*);
+void diff_free(struct diff_options*);
void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
/* diff-raw status letters */