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>

Michael Haggerty committed May 25, 2013 at 11:08 UTC 8c46bf904fe95105faaa1823332c91d2802182c2
1 file changed +4
notes.c
+4
@@ -927,8 +927,12 @@ static int string_list_add_one_ref(const char *refname, const unsigned char *sha
927 return 0;
928 }
929
930 +/*
931 + * The list argument must have strdup_strings set on it.
932 + */
933 void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
934 {
935 + assert(list->strdup_strings);
936 if (has_glob_specials(glob)) {
937 for_each_glob_ref(string_list_add_one_ref, glob, list);
938 } else {