Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: kmcguigan@twopensource.com
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/1] Don't free remote->name after fetch
Date: Tue, 14 Jun 2016 11:49:11 -0700	[thread overview]
Message-ID: <xmqqvb1b8v2w.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <1465928936-68866-1-git-send-email-kmcguigan@twopensource.com> (kmcguigan@twopensource.com's message of "Tue, 14 Jun 2016 14:28:56 -0400")

kmcguigan@twopensource.com writes:

> From: Keith McGuigan <kmcguigan@twopensource.com>
>
> Make fetch's string_list of remote names owns all of its string items
> (strdup'ing when necessary) so that it can deallocate them safely when
> clearing.
>
> ---

OK.

When I pointed out the call to string_list_append() in
get_remote_group() as one example, I did not check if there are
others that need similar adjustment.  I just skimmed through the
file again and it seems there is none, so this change looks good.

I assume you meant to sign this off, too?

>  builtin/fetch.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 630ae6a1bb78..1b4e924bd222 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -1071,7 +1071,7 @@ static int get_remote_group(const char *key, const char *value, void *priv)
>  			size_t wordlen = strcspn(value, " \t\n");
>  
>  			if (wordlen >= 1)
> -				string_list_append(g->list,
> +				string_list_append_nodup(g->list,
>  						   xstrndup(value, wordlen));
>  			value += wordlen + (value[wordlen] != '\0');
>  		}
> @@ -1261,7 +1261,7 @@ done:
>  int cmd_fetch(int argc, const char **argv, const char *prefix)
>  {
>  	int i;
> -	struct string_list list = STRING_LIST_INIT_NODUP;
> +	struct string_list list = STRING_LIST_INIT_DUP;
>  	struct remote *remote;
>  	int result = 0;
>  	struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
> @@ -1347,8 +1347,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
>  		argv_array_clear(&options);
>  	}
>  
> -	/* All names were strdup()ed or strndup()ed */
> -	list.strdup_strings = 1;
>  	string_list_clear(&list, 0);
>  
>  	close_all_packs();

  reply	other threads:[~2016-06-14 18:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 18:28 [PATCH v2 1/1] Don't free remote->name after fetch kmcguigan
2016-06-14 18:49 ` Junio C Hamano [this message]
2016-06-14 18:54   ` Keith McGuigan
2016-06-14 18:57     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqvb1b8v2w.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kmcguigan@twopensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox