On 2014-06-23 12.11, Tanay Abhra wrote: > The string-list API has STRING_LIST_INIT_* macros to be used > to define variables with initialisers, but lacks functions > to initialise an uninitialised piece of memory to be used as > a string-list at the run-time. > Introduce string_list_init_{dup,nodup}() functions for that. > > Signed-off-by: Tanay Abhra <tanayabh@xxxxxxxxx> > --- > string-list.c | 18 ++++++++++++++++++ > string-list.h | 3 +++ > 2 files changed, 21 insertions(+) > > diff --git a/string-list.c b/string-list.c > index aabb25e..8c3a4eb 100644 > --- a/string-list.c > +++ b/string-list.c > @@ -1,6 +1,24 @@ > #include "cache.h" > #include "string-list.h" > > +void string_list_init_nodup(struct string_list *list) > +{ > + list->items = NULL; > + list->nr = 0; > + list->alloc = 0; > + list->strdup_strings = 0; > + list->cmp = NULL; > +} > + If we look at the definition below: struct string_list { struct string_list_item *items; unsigned int nr, alloc; unsigned int strdup_strings:1; compare_strings_fn cmp; /* NULL uses strcmp() */ I think a simple memset() will be easier to read, and it will be more future proof: In case elements are added, the will have 0 or NULL automatically: void string_list_init_nodup(struct string_list *list) { memset (list, 0, sizeof(*list)); } (But then I wonder if we need the function at all ?) Or does it make sense to have a common function similar to this, which covers both cases: void string_list_init(struct string_list *list, int strdup_strings) { memset (list, 0, sizeof(*list)); list->strdup_strings = strdup_strings; } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html