Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--string-list.c18
-rw-r--r--string-list.h11
2 files changed, 25 insertions, 4 deletions
diff --git a/string-list.c b/string-list.c
index a917955fbd..43576ad126 100644
--- a/string-list.c
+++ b/string-list.c
@@ -1,10 +1,24 @@
#include "cache.h"
#include "string-list.h"
+void string_list_init_nodup(struct string_list *list)
+{
+ struct string_list blank = STRING_LIST_INIT_NODUP;
+ memcpy(list, &blank, sizeof(*list));
+}
+
+void string_list_init_dup(struct string_list *list)
+{
+ struct string_list blank = STRING_LIST_INIT_DUP;
+ memcpy(list, &blank, sizeof(*list));
+}
+
void string_list_init(struct string_list *list, int strdup_strings)
{
- memset(list, 0, sizeof(*list));
- list->strdup_strings = strdup_strings;
+ if (strdup_strings)
+ string_list_init_dup(list);
+ else
+ string_list_init_nodup(list);
}
/* if there is no exact match, point to the index where the entry could be
diff --git a/string-list.h b/string-list.h
index 521b9c0748..0d6b469239 100644
--- a/string-list.h
+++ b/string-list.h
@@ -97,8 +97,15 @@ struct string_list {
/* General functions which work with both sorted and unsorted lists. */
/**
- * Initialize the members of the string_list, set `strdup_strings`
- * member according to the value of the second parameter.
+ * Initialize the members of a string_list pointer in the same way as
+ * the corresponding `STRING_LIST_INIT_NODUP` and
+ * `STRING_LIST_INIT_DUP` macros.
+ */
+void string_list_init_nodup(struct string_list *list);
+void string_list_init_dup(struct string_list *list);
+
+/**
+ * TODO remove: For compatibility with any in-flight older API users
*/
void string_list_init(struct string_list *list, int strdup_strings);