Skip to content

Commit 8c46bf9

Browse files
mhaggergitster
authored andcommitted
string_list_add_refs_by_glob(): add a comment about memory management
Since string_list_add_one_ref() adds refname to the string list, but the lifetime of refname is limited, it is important that the string_list passed to string_list_add_one_ref() has strdup_strings set. Document this fact. All current callers do the right thing. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d235e99 commit 8c46bf9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

notes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,12 @@ static int string_list_add_one_ref(const char *refname, const unsigned char *sha
927927
return 0;
928928
}
929929

930+
/*
931+
* The list argument must have strdup_strings set on it.
932+
*/
930933
void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
931934
{
935+
assert(list->strdup_strings);
932936
if (has_glob_specials(glob)) {
933937
for_each_glob_ref(string_list_add_one_ref, glob, list);
934938
} else {

0 commit comments

Comments
 (0)