Subject: Re: [PATCH 16/24] revisions API: have release_revisions() release "mailmap"

From: Derrick Stolee <[email-masked]>
Date: Wed, 9 Mar 2022 14:17:01 -0500

On 3/9/2022 8:16 AM, Ævar Arnfjörð Bjarmason wrote:

> @@ -1097,7 +1097,7 @@ static const char *find_author_by_nickname(const char *name)
>  	struct rev_info revs;
>  	struct commit *commit;
>  	struct strbuf buf = STRBUF_INIT;
> -	struct string_list mailmap = STRING_LIST_INIT_NODUP;
> +	struct string_list *mailmap = xmalloc(sizeof(struct string_list));
>  	const char *av[20];
>  	int ac = 0;
>  
> @@ -1108,7 +1108,8 @@ static const char *find_author_by_nickname(const char *name)
>  	av[++ac] = buf.buf;
>  	av[++ac] = NULL;
>  	setup_revisions(ac, av, &revs, NULL);
> -	revs.mailmap = &mailmap;
> +	string_list_init_nodup(mailmap);
> +	revs.mailmap = mailmap;
>  	read_mailmap(revs.mailmap);
>  
>  	if (prepare_revision_walk(&revs))
> @@ -1119,7 +1120,6 @@ static const char *find_author_by_nickname(const char *name)
>  		ctx.date_mode.type = DATE_NORMAL;
>  		strbuf_release(&buf);
>  		format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
> -		clear_mailmap(&mailmap);

It seems like you can completely remove the 'mailmap' variable and
instead malloc and init revs.mailmap directly.

Thanks,
-Stolee