Re: [PATCH v2 22/25] string_list_add_refs_by_glob(): add a comment about memory management

2013-05-30 Thread Michael Haggerty
On 05/29/2013 10:21 AM, Thomas Rast wrote:
 Michael Haggerty mhag...@alum.mit.edu writes:
 
 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.
 [...]
 +/*
 + * The list argument must have strdup_strings set on it.
 + */
  void string_list_add_refs_by_glob(struct string_list *list, const char 
 *glob)
  {
  if (has_glob_specials(glob)) {
 
 Maybe add an assert() so that this is bulletproof?

Good idea.  Will be added in v3.

Michael

-- 
Michael Haggerty
mhag...@alum.mit.edu
http://softwareswirl.blogspot.com/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 22/25] string_list_add_refs_by_glob(): add a comment about memory management

2013-05-29 Thread Thomas Rast
Michael Haggerty mhag...@alum.mit.edu writes:

 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.
[...]
 +/*
 + * The list argument must have strdup_strings set on it.
 + */
  void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
  {
   if (has_glob_specials(glob)) {

Maybe add an assert() so that this is bulletproof?

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 22/25] string_list_add_refs_by_glob(): add a comment about memory management

2013-05-25 Thread Michael Haggerty
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 mhag...@alum.mit.edu
---
 notes.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/notes.c b/notes.c
index fa7cdf7..602d956 100644
--- a/notes.c
+++ b/notes.c
@@ -927,6 +927,9 @@ static int string_list_add_one_ref(const char *refname, 
const unsigned char *sha
return 0;
 }
 
+/*
+ * The list argument must have strdup_strings set on it.
+ */
 void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
 {
if (has_glob_specials(glob)) {
-- 
1.8.2.3

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html