reduce_heads: fix memory leaks
commit4da72644b768b0491110a8ba0aa84d32b6bde41c
authorMartin Ågren <martin.agren@gmail.com>
Tue, 7 Nov 2017 20:39:45 +0000 (7 21:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 8 Nov 2017 02:34:00 +0000 (8 11:34 +0900)
treebe9d8ddc0fc3d78e3d5aa2b80edbf396b7c2b566
parenta452d0f4bae99c9acef6f7db75f6f1d922618732
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>
builtin/commit.c
builtin/fmt-merge-msg.c
builtin/merge-base.c
builtin/merge.c
builtin/pull.c
commit.c
commit.h