Merge branch 'ps/leakfixes-more'
More memory leaks have been plugged. * ps/leakfixes-more: (29 commits) builtin/blame: fix leaking ignore revs files builtin/blame: fix leaking prefixed paths blame: fix leaking data for blame scoreboards line-range: plug leaking find functions merge: fix leaking merge bases builtin/merge: fix leaking `struct cmdnames` in `get_strategy()` sequencer: fix memory leaks in `make_script_with_merges()` builtin/clone: plug leaking HEAD ref in `wanted_peer_refs()` apply: fix leaking string in `match_fragment()` sequencer: fix leaking string buffer in `commit_staged_changes()` commit: fix leaking parents when calling `commit_tree_extended()` config: fix leaking "core.notesref" variable rerere: fix various trivial leaks builtin/stash: fix leak in `show_stash()` revision: free diff options builtin/log: fix leaking commit list in git-cherry(1) merge-recursive: fix memory leak when finalizing merge builtin/merge-recursive: fix leaking object ID bases builtin/difftool: plug memory leaks in `run_dir_diff()` object-name: free leaking object contexts ...
This commit is contained in:
21
notes.c
21
notes.c
@ -1064,6 +1064,12 @@ void init_display_notes(struct display_notes_opt *opt)
|
||||
{
|
||||
memset(opt, 0, sizeof(*opt));
|
||||
opt->use_default_notes = -1;
|
||||
string_list_init_dup(&opt->extra_notes_refs);
|
||||
}
|
||||
|
||||
void release_display_notes(struct display_notes_opt *opt)
|
||||
{
|
||||
string_list_clear(&opt->extra_notes_refs, 0);
|
||||
}
|
||||
|
||||
void enable_default_display_notes(struct display_notes_opt *opt, int *show_notes)
|
||||
@ -1077,19 +1083,15 @@ void enable_ref_display_notes(struct display_notes_opt *opt, int *show_notes,
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
strbuf_addstr(&buf, ref);
|
||||
expand_notes_ref(&buf);
|
||||
string_list_append(&opt->extra_notes_refs,
|
||||
strbuf_detach(&buf, NULL));
|
||||
string_list_append_nodup(&opt->extra_notes_refs,
|
||||
strbuf_detach(&buf, NULL));
|
||||
*show_notes = 1;
|
||||
}
|
||||
|
||||
void disable_display_notes(struct display_notes_opt *opt, int *show_notes)
|
||||
{
|
||||
opt->use_default_notes = -1;
|
||||
/* we have been strdup'ing ourselves, so trick
|
||||
* string_list into free()ing strings */
|
||||
opt->extra_notes_refs.strdup_strings = 1;
|
||||
string_list_clear(&opt->extra_notes_refs, 0);
|
||||
opt->extra_notes_refs.strdup_strings = 0;
|
||||
*show_notes = 0;
|
||||
}
|
||||
|
||||
@ -1221,11 +1223,16 @@ void prune_notes(struct notes_tree *t, int flags)
|
||||
for_each_note(t, 0, prune_notes_helper, &l);
|
||||
|
||||
while (l) {
|
||||
struct note_delete_list *next;
|
||||
|
||||
if (flags & NOTES_PRUNE_VERBOSE)
|
||||
printf("%s\n", hash_to_hex(l->sha1));
|
||||
if (!(flags & NOTES_PRUNE_DRYRUN))
|
||||
remove_note(t, l->sha1);
|
||||
l = l->next;
|
||||
|
||||
next = l->next;
|
||||
free(l);
|
||||
l = next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user