Re: [PATCH 21/24] revisions API: release "reflog_info" in release revisions()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/9/2022 8:16 AM, Ævar Arnfjörð Bjarmason wrote:
> 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@xxxxxxxxx>
> ---
>  reflog-walk.c            | 26 ++++++++++++++++++++++++--
>  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, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/reflog-walk.c b/reflog-walk.c
> index 8ac4b284b6b..4322228d122 100644
> --- a/reflog-walk.c
> +++ b/reflog-walk.c
> @@ -7,7 +7,7 @@
>  #include "reflog-walk.h"
>  
>  struct complete_reflogs {
> -	char *ref;
> +	const char *ref;
>  	const char *short_ref;

This seems like the opposite change from what I would
expect, because the 'const' implies non-ownership.

> -	free(array->ref);
> +	free((char *)array->ref);
> +	free((char *)array->short_ref);

This further makes the point that we should be keeping
non-const versions so we can clearly document ownership.

> +static void complete_reflogs_clear(void *util, const char *str)
> +{
> +	struct complete_reflogs *array = util;
> +	free_complete_reflog(array);
> +}

Is there a reason we don't do the cast inside?

	free_complete_reflog((struct complete_reflogs *)util);

Thanks,
-Stolee



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux