reduce_heads: fix memory leaks
We currently have seven callers of `reduce_heads(foo)`. Six of them do not use the original list `foo` again, and actually, all six of those end up leaking it. Introduce and use `reduce_heads_replace(&foo)` as a leak-free version of `foo = reduce_heads(foo)` to fix several of these. Fix the remaining leaks using `free_commit_list()`. While we're here, document `reduce_heads()` and mark it as `extern`. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a452d0f4ba
commit
4da72644b7
@ -745,12 +745,15 @@ static int get_octopus_merge_base(struct object_id *merge_base,
|
||||
if (!is_null_oid(fork_point))
|
||||
commit_list_insert(lookup_commit_reference(fork_point), &revs);
|
||||
|
||||
result = reduce_heads(get_octopus_merge_bases(revs));
|
||||
result = get_octopus_merge_bases(revs);
|
||||
free_commit_list(revs);
|
||||
reduce_heads_replace(&result);
|
||||
|
||||
if (!result)
|
||||
return 1;
|
||||
|
||||
oidcpy(merge_base, &result->item->object.oid);
|
||||
free_commit_list(result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user