From: Jonathan Nieder <jrnieder@gmail.com>
To: Thiago Farina <tfransosi@gmail.com>
Cc: git@vger.kernel.org
Subject: [demo/PATCH 1/3] string-list: introduce string_list_init()
Date: Sun, 5 Sep 2010 15:04:30 -0500 [thread overview]
Message-ID: <20100905200429.GB14497@burratino> (raw)
In-Reply-To: <20100905200323.GA14497@burratino>
Instead of asking callers to
memset(&list, 0, sizeof(list));
list.strdup_strings = strdup_strings;
we can take care of that ourselves, providing the flexibility
to change the details of string_list layout later if wanted.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
string-list.c | 7 +++++++
string-list.h | 1 +
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/string-list.c b/string-list.c
index 9b023a2..8e992a7 100644
--- a/string-list.c
+++ b/string-list.c
@@ -102,6 +102,13 @@ int for_each_string_list(struct string_list *list,
return ret;
}
+void string_list_init(struct string_list *list, int strdup_strings)
+{
+ list->items = NULL;
+ list->nr = list->alloc = 0;
+ list->strdup_strings = strdup_strings ? 1 : 0;
+}
+
void string_list_clear(struct string_list *list, int free_util)
{
if (list->items) {
diff --git a/string-list.h b/string-list.h
index 4946938..07e075c 100644
--- a/string-list.h
+++ b/string-list.h
@@ -15,6 +15,7 @@ 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(struct string_list *list, int strdup_strings);
void print_string_list(const struct string_list *p, const char *text);
void string_list_clear(struct string_list *list, int free_util);
--
1.7.2.3
next prev parent reply other threads:[~2010-09-05 20:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-05 17:51 [PATCH] Documentation: document the string-list macros Thiago Farina
2010-09-05 20:03 ` [demo/patch 0/3] " Jonathan Nieder
2010-09-05 20:04 ` Jonathan Nieder [this message]
2010-09-05 20:06 ` [demo/PATCH 1/3] string-list: Document STRING_LIST_INIT_* and string_list_init() Jonathan Nieder
2010-09-05 20:08 ` [demo/PATCH 3/3] Make initialization of string_lists more consistent Jonathan Nieder
2010-09-05 23:19 ` [demo/patch 0/3] Re: [PATCH] Documentation: document the string-list macros Thiago Farina
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=20100905200429.GB14497@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=tfransosi@gmail.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).