diff options
author | Martin Ågren <martin.agren@gmail.com> | 2017-11-07 21:39:45 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-08 11:34:00 +0900 |
commit | 4da72644b768b0491110a8ba0aa84d32b6bde41c (patch) | |
tree | be9d8ddc0fc3d78e3d5aa2b80edbf396b7c2b566 /commit.c | |
parent | builtin/merge-base: free commit lists (diff) | |
download | tgif-4da72644b768b0491110a8ba0aa84d32b6bde41c.tar.xz |
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>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -1090,6 +1090,13 @@ struct commit_list *reduce_heads(struct commit_list *heads) return result; } +void reduce_heads_replace(struct commit_list **heads) +{ + struct commit_list *result = reduce_heads(*heads); + free_commit_list(*heads); + *heads = result; +} + static const char gpg_sig_header[] = "gpgsig"; static const int gpg_sig_header_len = sizeof(gpg_sig_header) - 1; |