summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2023-10-05 21:30:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2023-10-05 21:54:57 (GMT)
commit8ef8da484272587c5c30810e5fcb03b4048a1221 (patch)
treec22c4ee43ed93c4ac6ac22f81a7beac87aefe00a /revision.c
parent771868243cf0b6f7edcec6e672d20faa4e9b50be (diff)
downloadgit-8ef8da484272587c5c30810e5fcb03b4048a1221.zip
git-8ef8da484272587c5c30810e5fcb03b4048a1221.tar.gz
git-8ef8da484272587c5c30810e5fcb03b4048a1221.tar.bz2
revision: clear decoration structs during release_revisions()
The point of release_revisions() is to free memory associated with the rev_info struct, but we have several "struct decoration" members that are left untouched. Since the previous commit introduced a function to do that, we can just call it. We do have to provide some specialized callbacks to map the void pointers onto real ones (the alternative would be casting the existing function pointers; this generally works because "void *" is usually interchangeable with a struct pointer, but it is technically forbidden by the standard). Since the line-log code does not expose the type it stores in the decoration (nor of course the function to free it), I put this behind a generic line_log_free() entry point. It's possible we may need to add more line-log specific bits anyway (running t4211 shows a number of other leaks in the line-log code). While this doubtless cleans up many leaks triggered by the test suite, the only script which becomes leak-free is t4217, as it does very little beyond a simple traversal (its existing leak was from the use of --children, which is now fixed). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/revision.c b/revision.c
index 2f4c53e..0ae1c76 100644
--- a/revision.c
+++ b/revision.c
@@ -3076,6 +3076,11 @@ static void release_revisions_mailmap(struct string_list *mailmap)
static void release_revisions_topo_walk_info(struct topo_walk_info *info);
+static void free_void_commit_list(void *list)
+{
+ free_commit_list(list);
+}
+
void release_revisions(struct rev_info *revs)
{
free_commit_list(revs->commits);
@@ -3093,6 +3098,10 @@ void release_revisions(struct rev_info *revs)
diff_free(&revs->pruning);
reflog_walk_info_release(revs->reflog_info);
release_revisions_topo_walk_info(revs->topo_walk_info);
+ clear_decoration(&revs->children, free_void_commit_list);
+ clear_decoration(&revs->merge_simplification, free);
+ clear_decoration(&revs->treesame, free);
+ line_log_free(revs);
}
static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)