Subject: Re: [PATCH v2 18/27] revisions API: have release_revisions() release "cmdline"

From: Junio C Hamano <[email-masked]>
Date: Thu, 24 Mar 2022 18:16:36 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> in-flight semantic conflicts.
>
> 1. https://lore.kernel.org/git/[email-masked]/
> 2. https://lore.kernel.org/git/[email-masked]/
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <[email-masked]>
>
> fixup with bc0e0439040?

WTH is this line?

> diff --git a/revision.c b/revision.c
> index d9e2b171f6d..f44298299a4 100644
> --- a/revision.c
> +++ b/revision.c
> @@ -2933,6 +2933,17 @@ static void release_revisions_commit_list(struct rev_info *revs)
>  	revs->commits = NULL;
>  }
>  
> +static void release_revisions_cmdline(struct rev_cmdline_info *cmdline)
> +{
> +	unsigned int i;
> +
> +	if (!cmdline)
> +		return;
> +	for (i = 0; i < cmdline->nr; i++)
> +		free((char *)cmdline->rev[i].name);
> +	FREE_AND_NULL(cmdline->rev);
> +}
> +
>  static void release_revisions_mailmap(struct string_list *mailmap)
>  {
>  	if (!mailmap)
> @@ -2947,6 +2958,7 @@ void release_revisions(struct rev_info *revs)
>  		return;
>  	release_revisions_commit_list(revs);
>  	object_array_clear(&revs->pending);
> +	release_revisions_cmdline(&revs->cmdline);
>  	release_revisions_mailmap(revs->mailmap);
>  }

That patch is quite unexpectedly small ;-)

When I created cmdline, I recall liberally stuffing borrowed strings
in the array, sort-of knowinly making it unnecessarily hard to
"free".

Quite pleasing.