transport: simplify duplicating a substring in transport_get() using xmemdupz()

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2014-12-24 01:18:31 +01:00 committed by Junio C Hamano
parent c2e8e4b9da
commit 6b33894f99

View File

@ -971,9 +971,7 @@ struct transport *transport_get(struct remote *remote, const char *url)
} else {
/* Unknown protocol in URL. Pass to external handler. */
int len = external_specification_len(url);
char *handler = xmalloc(len + 1);
handler[len] = 0;
strncpy(handler, url, len);
char *handler = xmemdupz(url, len);
transport_helper_init(ret, handler);
}