remote.c: make singular free_ref() public
authorJeff King <peff@peff.net>
Sat, 13 Apr 2019 05:54:31 +0000 (01:54 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Apr 2019 05:00:52 +0000 (14:00 +0900)
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>
remote.c
remote.h
index 9cc3b07d214a63271849243c5f823b8f87ad631b..3fe34eae853851f16271e0500b827ef855c30f14 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -820,11 +820,11 @@ struct ref *copy_ref_list(const struct ref *ref)
        return ret;
 }
 
-static void free_ref(struct ref *ref)
+void free_one_ref(struct ref *ref)
 {
        if (!ref)
                return;
-       free_ref(ref->peer_ref);
+       free_one_ref(ref->peer_ref);
        free(ref->remote_status);
        free(ref->symref);
        free(ref);
@@ -835,7 +835,7 @@ void free_refs(struct ref *ref)
        struct ref *next;
        while (ref) {
                next = ref->next;
-               free_ref(ref);
+               free_one_ref(ref);
                ref = next;
        }
 }
index da53ad570b91dbd4a820ffc79541fb0a4915ff6b..f58332a27e96ee9e3ec7bea53e7889d62a0140a2 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -131,8 +131,10 @@ int ref_compare_name(const void *, const void *);
 int check_ref_type(const struct ref *ref, int flags);
 
 /*
- * Frees the entire list and peers of elements.
+ * Free a single ref and its peer, or an entire list of refs and their peers,
+ * respectively.
  */
+void free_one_ref(struct ref *ref);
 void free_refs(struct ref *ref);
 
 struct oid_array;