Skip to content

Commit 3f721d1

Browse files
bertwesarggitster
authored andcommitted
builtin-remote: (get_one_entry): use strbuf
Signed-off-by: Bert Wesarg <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 916e137 commit 3f721d1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

builtin-remote.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,15 +1276,14 @@ static int update(int argc, const char **argv)
12761276
static int get_one_entry(struct remote *remote, void *priv)
12771277
{
12781278
struct string_list *list = priv;
1279+
struct strbuf url_buf = STRBUF_INIT;
12791280
const char **url;
12801281
int i, url_nr;
1281-
void **utilp;
12821282

12831283
if (remote->url_nr > 0) {
1284-
utilp = &(string_list_append(remote->name, list)->util);
1285-
*utilp = xmalloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
1286-
strcpy((char *) *utilp, remote->url[0]);
1287-
strcat((char *) *utilp, " (fetch)");
1284+
strbuf_addf(&url_buf, "%s (fetch)", remote->url[0]);
1285+
string_list_append(remote->name, list)->util =
1286+
strbuf_detach(&url_buf, NULL);
12881287
} else
12891288
string_list_append(remote->name, list)->util = NULL;
12901289
if (remote->pushurl_nr) {
@@ -1296,10 +1295,9 @@ static int get_one_entry(struct remote *remote, void *priv)
12961295
}
12971296
for (i = 0; i < url_nr; i++)
12981297
{
1299-
utilp = &(string_list_append(remote->name, list)->util);
1300-
*utilp = xmalloc(strlen(url[i])+strlen(" (push)")+1);
1301-
strcpy((char *) *utilp, url[i]);
1302-
strcat((char *) *utilp, " (push)");
1298+
strbuf_addf(&url_buf, "%s (push)", url[i]);
1299+
string_list_append(remote->name, list)->util =
1300+
strbuf_detach(&url_buf, NULL);
13031301
}
13041302

13051303
return 0;

0 commit comments

Comments
 (0)