From 8e804415fd3183f56ced0dcc168f8cb4aa790473 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 14 Jun 2024 06:28:01 -0400 Subject: remote: use strvecs to store remote url/pushurl Now that the url/pushurl fields of "struct remote" own their strings, we can switch from bare arrays to strvecs. This has a few advantages: - push/clear are now one-liners - likewise the free+assigns in alias_all_urls() can use strvec_replace() - we now use size_t for storage, avoiding possible overflow - this will enable some further cleanups in future patches There's quite a bit of fallout in the code that reads these fields, as it tends to access these arrays directly. But it's mostly a mechanical replacement of "url_nr" with "url.nr", and "url[i]" with "url.v[i]", with a few variations (e.g. "*url" could become "*url.v", but I used "url.v[0]" for consistency). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- remote.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'remote.h') diff --git a/remote.h b/remote.h index e8c6655e42..84dc91cca0 100644 --- a/remote.h +++ b/remote.h @@ -4,6 +4,7 @@ #include "hash-ll.h" #include "hashmap.h" #include "refspec.h" +#include "strvec.h" struct option; struct transport_ls_refs_options; @@ -68,16 +69,9 @@ struct remote { char *foreign_vcs; /* An array of all of the url_nr URLs configured for the remote */ - const char **url; - - int url_nr; - int url_alloc; - + struct strvec url; /* An array of all of the pushurl_nr push URLs configured for the remote */ - const char **pushurl; - - int pushurl_nr; - int pushurl_alloc; + struct strvec pushurl; struct refspec push; -- cgit v1.3-6-g1900