remote.c: make singular free_ref() public
We provide a free_refs() function to free a list, but there's no easy way for a caller to free a single ref. Let's make our singular free_ref() function public. Since its name is so similar to the list-freeing free_refs(), and because both of those functions have the same signature, it might be easy to accidentally use the wrong one. Let's call the singular version the more verbose "free_one_ref()" to distinguish it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Apr 13, 2019 at 01:54 UTC
1027186fdd3bb55b2149693550542e0647feb7a3
2 files changed
+6
-4
remote.c
+3
-3
@@ -820,11 +820,11 @@ struct ref *copy_ref_list(const struct ref *ref)
820
return ret;
821
}
822
823
-static void free_ref(struct ref *ref)
823
+void free_one_ref(struct ref *ref)
824
{
825
if (!ref)
826
return;
827
- free_ref(ref->peer_ref);
827
+ free_one_ref(ref->peer_ref);
828
free(ref->remote_status);
829
free(ref->symref);
830
free(ref);
@@ -835,7 +835,7 @@ void free_refs(struct ref *ref)
835
struct ref *next;
836
while (ref) {
837
next = ref->next;
838
- free_ref(ref);
838
+ free_one_ref(ref);
839
ref = next;
840
}
841
}
remote.h
+3
-1
@@ -131,8 +131,10 @@ int ref_compare_name(const void *, const void *);
131
int check_ref_type(const struct ref *ref, int flags);
132
133
/*
134
- * Frees the entire list and peers of elements.
134
+ * Free a single ref and its peer, or an entire list of refs and their peers,
135
+ * respectively.
136
*/
137
+void free_one_ref(struct ref *ref);
138
void free_refs(struct ref *ref);
139
140
struct oid_array;