diff: remove parseopts member from struct diff_options

repo_diff_setup() builds the struct option array with git diff's command
line options and stores a pointer to it in the parseopts member of
struct diff_options.  The array is freed by diff_setup_done(), but not
by release_revisions().  Thus calling only repo_diff_setup() and
release_revisions() leaks that array.

We could free it in release_revisions() as well to plug that leak, but
there is a better way: Only build it when needed.  Absorb
prep_parse_options() into the last place that uses the parseopts member
of struct diff_options, add_diff_parseopts(), and get rid of said
member.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2022-12-01 23:53:17 +01:00
committed by Junio C Hamano
parent 6c6048fa7f
commit 189e97bc4b
2 changed files with 1 additions and 15 deletions

1
diff.h
View File

@ -394,7 +394,6 @@ struct diff_options {
unsigned color_moved_ws_handling;
struct repository *repo;
struct option *parseopts;
struct strmap *additional_path_headers;
int no_free;