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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
fa3f60b783
commit
95244ae3dd
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user