From: Tanay Abhra <tanayabh@gmail.com>
To: git@vger.kernel.org
Cc: Tanay Abhra <tanayabh@gmail.com>,
Ramkumar Ramachandra <artagnon@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v2 1/2] string-list: Add string_list initializer helper functions
Date: Mon, 16 Jun 2014 01:27:11 -0700 [thread overview]
Message-ID: <1402907232-24629-2-git-send-email-tanayabh@gmail.com> (raw)
In-Reply-To: <1402907232-24629-1-git-send-email-tanayabh@gmail.com>
When a compound construct like a string_list within another
struct is used, the default initializer macros are useless.
For such cases add helper functions for string_list
initialization for both DUP and NODUP modes.
Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
---
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;
+}
+
+void string_list_init_dup(struct string_list *list)
+{
+ list->items = NULL;
+ list->nr = 0;
+ list->alloc = 0;
+ list->strdup_strings = 1;
+ list->cmp = NULL;
+}
+
/* if there is no exact match, point to the index where the entry could be
* inserted */
static int get_entry_index(const struct string_list *list, const char *string,
diff --git a/string-list.h b/string-list.h
index de6769c..8ae3376 100644
--- a/string-list.h
+++ b/string-list.h
@@ -18,6 +18,9 @@ struct string_list {
#define STRING_LIST_INIT_NODUP { NULL, 0, 0, 0 }
#define STRING_LIST_INIT_DUP { NULL, 0, 0, 1 }
+void string_list_init_nodup(struct string_list *list);
+void string_list_init_dup(struct string_list *list);
+
void print_string_list(const struct string_list *p, const char *text);
void string_list_clear(struct string_list *list, int free_util);
--
1.9.0.GIT
next prev parent reply other threads:[~2014-06-16 8:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 8:27 [PATCH v2 0/2] Git config cache & special querying api utilizing the cache Tanay Abhra
2014-06-16 8:27 ` Tanay Abhra [this message]
2014-06-16 22:59 ` [PATCH v2 1/2] string-list: Add string_list initializer helper functions Junio C Hamano
2014-06-17 19:05 ` Tanay Abhra
2014-06-17 22:10 ` Junio C Hamano
2014-06-16 8:27 ` [PATCH v2 2/2] config: Add hashtable for config parsing & retrieval Tanay Abhra
2014-06-16 17:11 ` Matthieu Moy
2014-06-16 17:28 ` Tanay Abhra
2014-06-16 17:35 ` Matthieu Moy
2014-06-17 5:34 ` Jeff King
2014-06-17 5:46 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1402907232-24629-2-git-send-email-tanayabh@gmail.com \
--to=tanayabh@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).