Re: [PATCH v5 23/27] revisions API: release "reflog_info" in release revisions()
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Apr 3, 2022, 15:19 UTC
- Message-ID
- <e71173fc-1b75-cc1e-df8e-efad512bf173@gmail.com>
- In-Reply-To
- <patch-v5-23.27-0e9745d9ee1-20220402T102002Z-avarab@gmail.com>
Hi Ævar
[It appears I forgot to press send earlier]
On 02/04/2022 11:49, Ævar Arnfjörð Bjarmason wrote:
Show 25 quoted lines
> Add a missing reflog_walk_info_release() to "reflog-walk.c" and use it
> in release_revisions().
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> reflog-walk.c | 24 +++++++++++++++++++++++-
> reflog-walk.h | 1 +
> revision.c | 1 +
> t/t0100-previous.sh | 1 +
> t/t1401-symbolic-ref.sh | 2 ++
> t/t1411-reflog-show.sh | 1 +
> t/t1412-reflog-loop.sh | 2 ++
> t/t1415-worktree-refs.sh | 1 +
> 8 files changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/reflog-walk.c b/reflog-walk.c
> index 8ac4b284b6b..7aa6595a51f 100644
> --- a/reflog-walk.c
> +++ b/reflog-walk.c
> @@ -8,7 +8,7 @@
>
> struct complete_reflogs {
> char *ref;
> - const char *short_ref;
> + char *short_ref;As this struct is only used internally I think changing the type rather than casting when we free it makes sense.
Best Wishes
Phillip
Show 128 quoted lines
> struct reflog_info {
> struct object_id ooid, noid;
> char *email;
> @@ -51,9 +51,16 @@ static void free_complete_reflog(struct complete_reflogs *array)
> }
> free(array->items);
> free(array->ref);
> + free(array->short_ref);
> free(array);
> }
>
> +static void complete_reflogs_clear(void *util, const char *str)
> +{
> + struct complete_reflogs *array = util;
> + free_complete_reflog(array);
> +}
> +
> static struct complete_reflogs *read_complete_reflog(const char *ref)
> {
> struct complete_reflogs *reflogs =
> @@ -116,6 +123,21 @@ void init_reflog_walk(struct reflog_walk_info **info)
> (*info)->complete_reflogs.strdup_strings = 1;
> }
>
> +void reflog_walk_info_release(struct reflog_walk_info *info)
> +{
> + size_t i;
> +
> + if (!info)
> + return;
> +
> + for (i = 0; i < info->nr; i++)
> + free(info->logs[i]);
> + string_list_clear_func(&info->complete_reflogs,
> + complete_reflogs_clear);
> + free(info->logs);
> + free(info);
> +}
> +
> int add_reflog_for_walk(struct reflog_walk_info *info,
> struct commit *commit, const char *name)
> {
> diff --git a/reflog-walk.h b/reflog-walk.h
> index e9e00ffd479..8076f10d9fb 100644
> --- a/reflog-walk.h
> +++ b/reflog-walk.h
> @@ -8,6 +8,7 @@ struct reflog_walk_info;
> struct date_mode;
>
> void init_reflog_walk(struct reflog_walk_info **info);
> +void reflog_walk_info_release(struct reflog_walk_info *info);
> int add_reflog_for_walk(struct reflog_walk_info *info,
> struct commit *commit, const char *name);
> void show_reflog_message(struct reflog_walk_info *info, int,
> diff --git a/revision.c b/revision.c
> index 40f59c441f7..e972addd8fc 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -2955,6 +2955,7 @@ void release_revisions(struct rev_info *revs)
> clear_pathspec(&revs->prune_data);
> release_revisions_mailmap(revs->mailmap);
> free_grep_patterns(&revs->grep_filter);
> + reflog_walk_info_release(revs->reflog_info);
> }
>
> static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
> diff --git a/t/t0100-previous.sh b/t/t0100-previous.sh
> index 69beb59f627..a16cc3d2983 100755
> --- a/t/t0100-previous.sh
> +++ b/t/t0100-previous.sh
> @@ -5,6 +5,7 @@ test_description='previous branch syntax @{-n}'
> GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
> export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>
> +TEST_PASSES_SANITIZE_LEAK=true
> . ./test-lib.sh
>
> test_expect_success 'branch -d @{-1}' '
> diff --git a/t/t1401-symbolic-ref.sh b/t/t1401-symbolic-ref.sh
> index 132a1b885ac..9fb0b90f252 100755
> --- a/t/t1401-symbolic-ref.sh
> +++ b/t/t1401-symbolic-ref.sh
> @@ -1,6 +1,8 @@
> #!/bin/sh
>
> test_description='basic symbolic-ref tests'
> +
> +TEST_PASSES_SANITIZE_LEAK=true
> . ./test-lib.sh
>
> # If the tests munging HEAD fail, they can break detection of
> diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
> index 0bb319b944a..3770ceffafd 100755
> --- a/t/t1411-reflog-show.sh
> +++ b/t/t1411-reflog-show.sh
> @@ -4,6 +4,7 @@ test_description='Test reflog display routines'
> GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
> export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>
> +TEST_PASSES_SANITIZE_LEAK=true
> . ./test-lib.sh
>
> test_expect_success 'setup' '
> diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh
> index 977603f7f1c..ff30874f940 100755
> --- a/t/t1412-reflog-loop.sh
> +++ b/t/t1412-reflog-loop.sh
> @@ -1,6 +1,8 @@
> #!/bin/sh
>
> test_description='reflog walk shows repeated commits again'
> +
> +TEST_PASSES_SANITIZE_LEAK=true
> . ./test-lib.sh
>
> test_expect_success 'setup commits' '
> diff --git a/t/t1415-worktree-refs.sh b/t/t1415-worktree-refs.sh
> index a3e6ea08088..3b531842dd4 100755
> --- a/t/t1415-worktree-refs.sh
> +++ b/t/t1415-worktree-refs.sh
> @@ -2,6 +2,7 @@
>
> test_description='per-worktree refs'
>
> +TEST_PASSES_SANITIZE_LEAK=true
> . ./test-lib.sh
>
> test_expect_success 'setup' '