commit-graph: clean up leaked memory during write
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 3 Oct 2018 17:12:15 +0000 (10:12 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 6 Oct 2018 23:25:05 +0000 (08:25 +0900)
commitf4dbdfc4d514d4ea558703f5a234652dc68d83b2
treed2a849f5ff05e35b8204efea7c82cf9bc3f2e1a5
parent6b89a34c89fc763292f06012318b852b74825619
commit-graph: clean up leaked memory during write

The write_commit_graph() method in commit-graph.c leaks some lits
and strings during execution. In addition, a list of strings is
leaked in write_commit_graph_reachable(). Clean these up so our
memory checking is cleaner.

Further, if we use a list of pack-files to find the commits, we
can leak the packed_git structs after scanning them for commits.

Running the following commands demonstrates the leak before and
the fix after:

* valgrind --leak-check=full ./git commit-graph write --reachable
* valgrind --leak-check=full ./git commit-graph write --stdin-packs

Signed-off-by: Martin Ă…gren <martin.agren@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit-graph.c