summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorMartin Ågren <martin.agren@gmail.com>2017-11-07 20:39:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-11-08 02:33:58 (GMT)
commita452d0f4bae99c9acef6f7db75f6f1d922618732 (patch)
tree2494d00952bcd01cf435b41b236b1d62b3d68913 /commit.c
parentcb5918aa0d50f50e83787f65c2ddc3dcb10159fe (diff)
downloadgit-a452d0f4bae99c9acef6f7db75f6f1d922618732.zip
git-a452d0f4bae99c9acef6f7db75f6f1d922618732.tar.gz
git-a452d0f4bae99c9acef6f7db75f6f1d922618732.tar.bz2
builtin/merge-base: free commit lists
In several functions, we iterate through a commit list by assigning `result = result->next`. As a consequence, we lose the original pointer and eventually leak the list. Rewrite the loops so that we keep the original pointers, then call `free_commit_list()`. Various alternatives were considered: 1) Use `UNLEAK(result)` before the loop. Simple change, but not very pretty. These would definitely be new lows among our usages of UNLEAK. 2) Use `pop_commit()` when looping. Slightly less simple change, but it feels slightly preferable to first display the list, then free it. 3) As in this patch, but with `UNLEAK()` instead of freeing. We'd still go through all the trouble of refactoring the loop, and because it's not super-obvious that we're about to exit, let's just free the lists -- it probably doesn't affect the runtime much. In `handle_independent()` we can drop `result` while we're here and reuse the `revs`-variable instead. That matches several other users of `reduce_heads()`. The memory-leak that this hides will be addressed in the next commit. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
0 files changed, 0 insertions, 0 deletions