summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-06-05 09:18:13 +0900
committerJunio C Hamano <gitster@pobox.com>2017-06-05 09:18:13 +0900
commit6e9b0108c6515510580da1698af893263f8cd7de (patch)
treeefc8f1d04801437acc457d1eb07ff0af636ed8c5 /remote.c
parenta12bfb2bfb8f3c0b257e60a6f697a254f5058c72 (diff)
parenta56eea28c45a8f76e4167c4e6baa87e89b7be3bc (diff)
downloadgit-6e9b0108c6515510580da1698af893263f8cd7de.tar.gz
Merge branch 'jk/drop-free-refspecs'
Code clean-up. * jk/drop-free-refspecs: remote: drop free_refspecs() function
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/remote.c b/remote.c
index e43b1460f8..3649d60cdc 100644
--- a/remote.c
+++ b/remote.c
@@ -477,26 +477,6 @@ static void read_config(void)
alias_all_urls();
}
-/*
- * This function frees a refspec array.
- * Warning: code paths should be checked to ensure that the src
- * and dst pointers are always freeable pointers as well
- * as the refspec pointer itself.
- */
-static void free_refspecs(struct refspec *refspec, int nr_refspec)
-{
- int i;
-
- if (!refspec)
- return;
-
- for (i = 0; i < nr_refspec; i++) {
- free(refspec[i].src);
- free(refspec[i].dst);
- }
- free(refspec);
-}
-
static struct refspec *parse_refspec_internal(int nr_refspec, const char **refspec, int fetch, int verify)
{
int i;
@@ -610,7 +590,7 @@ static struct refspec *parse_refspec_internal(int nr_refspec, const char **refsp
* since it is only possible to reach this point from within
* the for loop above.
*/
- free_refspecs(rs, i+1);
+ free_refspec(i+1, rs);
return NULL;
}
die("Invalid refspec '%s'", refspec[i]);
@@ -621,7 +601,7 @@ int valid_fetch_refspec(const char *fetch_refspec_str)
struct refspec *refspec;
refspec = parse_refspec_internal(1, &fetch_refspec_str, 1, 1);
- free_refspecs(refspec, 1);
+ free_refspec(1, refspec);
return !!refspec;
}
@@ -638,6 +618,10 @@ struct refspec *parse_push_refspec(int nr_refspec, const char **refspec)
void free_refspec(int nr_refspec, struct refspec *refspec)
{
int i;
+
+ if (!refspec)
+ return;
+
for (i = 0; i < nr_refspec; i++) {
free(refspec[i].src);
free(refspec[i].dst);