diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-06-11 11:19:45 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-06-11 13:15:05 -0700 |
commit | 97485374377fa62fdd36f4b707e2fcd8f1a7c6c3 (patch) | |
tree | f37b7563648e311dc7f7d86f179bb38731e6c0b5 /notes.h | |
parent | 3d31d382557527bf945a088931e3e28a717cc547 (diff) |
revision: fix leaking display notes
We never free the display notes options embedded into `struct revision`.
Implement a new function `release_display_notes()` that we can call in
`release_revisions()` to fix this.
There is another gotcha here though: we play some games with the string
list used to track extra notes refs, where we sometimes set the bit that
indicates that strings should be strdup'd and sometimes unset it. This
dance is done to avoid a copy of an already-allocated string when we
call `enable_ref_display_notes()`. But this dance is rather pointless as
we can instead call `string_list_append_nodup()` to transfer ownership
of the allocated string to the list.
Refactor the code to do so and drop the `strdup_strings` dance.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes.h')
-rw-r--r-- | notes.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -276,6 +276,11 @@ struct display_notes_opt { void init_display_notes(struct display_notes_opt *opt); /* + * Release resources acquired by the display_notes_opt. + */ +void release_display_notes(struct display_notes_opt *opt); + +/* * This family of functions enables or disables the display of notes. In * particular, 'enable_default_display_notes' will display the default notes, * 'enable_ref_display_notes' will display the notes ref 'ref' and |