Skip to content

Commit 1027186

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 259eddd commit 1027186

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

remote.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,11 @@ struct ref *copy_ref_list(const struct ref *ref)
820820
return ret;
821821
}
822822

823-
static void free_ref(struct ref *ref)
823+
void free_one_ref(struct ref *ref)
824824
{
825825
if (!ref)
826826
return;
827-
free_ref(ref->peer_ref);
827+
free_one_ref(ref->peer_ref);
828828
free(ref->remote_status);
829829
free(ref->symref);
830830
free(ref);
@@ -835,7 +835,7 @@ void free_refs(struct ref *ref)
835835
struct ref *next;
836836
while (ref) {
837837
next = ref->next;
838-
free_ref(ref);
838+
free_one_ref(ref);
839839
ref = next;
840840
}
841841
}

remote.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ int ref_compare_name(const void *, const void *);
131131
int check_ref_type(const struct ref *ref, int flags);
132132

133133
/*
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.
135136
*/
137+
void free_one_ref(struct ref *ref);
136138
void free_refs(struct ref *ref);
137139

138140
struct oid_array;

0 commit comments

Comments
 (0)