From 95244ae3dd49b3eed4dbfe09299b9d8847622218 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 19 Jun 2014 17:19:43 -0400 Subject: use xstrdup instead of xmalloc + strcpy This is one line shorter, and makes sure the length in the malloc and copy steps match. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- http-walker.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'http-walker.c') diff --git a/http-walker.c b/http-walker.c index 1516c5eb29..ab6a4febeb 100644 --- a/http-walker.c +++ b/http-walker.c @@ -566,8 +566,7 @@ struct walker *get_http_walker(const char *url) struct walker *walker = xmalloc(sizeof(struct walker)); data->alt = xmalloc(sizeof(*data->alt)); - data->alt->base = xmalloc(strlen(url) + 1); - strcpy(data->alt->base, url); + data->alt->base = xstrdup(url); for (s = data->alt->base + strlen(data->alt->base) - 1; *s == '/'; --s) *s = 0; -- cgit v1.2.3