]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revisions API users: use release_revisions() with UNLEAK()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 13 Apr 2022 20:01:43 +0000 (22:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Apr 2022 06:56:09 +0000 (23:56 -0700)
Use a release_revisions() with those "struct rev_list" users which
already "UNLEAK" the struct. It may seem odd to simultaneously attempt
to free() memory, but also to explicitly ignore whether we have memory
leaks in the same.

As explained in preceding commits this is being done to use the
built-in commands as a guinea pig for whether the release_revisions()
function works as expected, we'd like to test e.g. whether we segfault
as we change it. In subsequent commits we'll then remove these
UNLEAK() as the function is made to free the memory that caused us to
add them in the first place.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/diff-index.c
builtin/diff.c

index 5fd23ab5b6c5b634be82e91339d4920fe9e15b99..3a83183c31232c818ffec6f7156901a77d861898 100644 (file)
@@ -71,5 +71,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
        }
        result = run_diff_index(&rev, option);
        UNLEAK(rev);
-       return diff_result_code(&rev.diffopt, result);
+       result = diff_result_code(&rev.diffopt, result);
+       release_revisions(&rev);
+       return result;
 }
index bb7fafca61815460ba085859322314b4c41c8b6b..dd48336da567b384966ebd1fe6e4fa489a6b3f60 100644 (file)
@@ -595,6 +595,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        if (1 < rev.diffopt.skip_stat_unmatch)
                refresh_index_quietly();
        UNLEAK(rev);
+       release_revisions(&rev);
        UNLEAK(ent);
        UNLEAK(blob);
        return result;