diff mbox series

[v3,21/27] global: drop `UNLEAK()` annotation

Message ID 20241120-b4-pks-leak-fixes-pt10-v3-21-d67f08f45c74@pks.im (mailing list archive)
State New
Headers show
Series Memory leak fixes (pt.10, final) | expand

Commit Message

Patrick Steinhardt Nov. 20, 2024, 1:39 p.m. UTC
There are two users of `UNLEAK()` left in our codebase:

  - In "builtin/clone.c", annotating the `repo` variable. That leak has
    already been fixed though as you can see in the context, where we do
    know to free `repo_to_free`.

  - In "builtin/diff.c", to unleak entries of the `blob[]` array. That
    leak has also been fixed, because the entries we assign to that
    array come from `rev.pending.objects`, and we do eventually release
    `rev`.

This neatly demonstrates one of the issues with `UNLEAK()`: it is quite
easy for the annotation to become stale. A second issue is that its
whole intent is to paper over leaks. And while that has been a necessary
evil in the past, because Git was leaking left and right, it isn't
really much of an issue nowadays where our test suite has no known leaks
anymore.

Remove the last two users of this macro.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 builtin/clone.c | 1 -
 builtin/diff.c  | 1 -
 2 files changed, 2 deletions(-)
diff mbox series

Patch

diff --git a/builtin/clone.c b/builtin/clone.c
index 59fcb317a68a77eee3ca96a60720c556e044c369..e851b1475d7be8f0af78c27d4ef15467a2769a74 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1586,7 +1586,6 @@  int cmd_clone(int argc,
 	free(dir);
 	free(path);
 	free(repo_to_free);
-	UNLEAK(repo);
 	junk_mode = JUNK_LEAVE_ALL;
 
 	transport_ls_refs_options_release(&transport_ls_refs_options);
diff --git a/builtin/diff.c b/builtin/diff.c
index dca52d4221ed19d27950bee9022ae7efb1d2f17a..2fe92f373e9991489fcaeeba381bbfe017a5316a 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -628,6 +628,5 @@  int cmd_diff(int argc,
 	release_revisions(&rev);
 	object_array_clear(&ent);
 	symdiff_release(&sdiff);
-	UNLEAK(blob);
 	return result;
 }