git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tanay Abhra <tanayabh@gmail.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: git@vger.kernel.org, Ramkumar Ramachandra <artagnon@gmail.com>,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Subject: Re: [PATCH v3 1/3] string-list: add string_list initialiser helper functions
Date: Mon, 23 Jun 2014 06:19:52 -0700	[thread overview]
Message-ID: <53A82978.2010900@gmail.com> (raw)
In-Reply-To: <53A81F45.70802@web.de>

On 06/23/2014 05:36 AM, Torsten Bögershausen wrote:
> 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:

Yes, you are right. After sending the patch I saw that for string_list
initialization the codebase either uses xcalloc or memset and after that
marks the list as DUP or NODUP.

> 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;
> }
> 

A common function would be much better as other API constructs as strbuf
have runtime init functions like the version you have shown above.

Thanks for the review.

  reply	other threads:[~2014-06-23 13:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 10:11 [PATCH v3 0/3] git config cache & special querying api utilizing the cache Tanay Abhra
2014-06-23 10:11 ` [PATCH v3 1/3] string-list: add string_list initialiser helper functions Tanay Abhra
2014-06-23 12:36   ` Torsten Bögershausen
2014-06-23 13:19     ` Tanay Abhra [this message]
2014-06-23 10:11 ` [PATCH v3 2/3] config: add hashtable for config parsing & retrieval Tanay Abhra
2014-06-23 11:55   ` Matthieu Moy
2014-06-24 12:06     ` Tanay Abhra
2014-06-25 20:25       ` Karsten Blees
2014-06-23 14:57   ` Ramsay Jones
2014-06-23 16:20     ` Tanay Abhra
2014-06-24 15:32       ` Ramsay Jones
2014-06-26 16:15         ` Matthieu Moy
2014-06-23 23:25     ` Junio C Hamano
2014-06-24  7:23       ` Tanay Abhra
2014-06-25 18:21         ` Junio C Hamano
2014-06-24  7:25       ` Tanay Abhra
2014-06-24 15:57       ` Ramsay Jones
2014-06-25 18:13         ` Junio C Hamano
2014-06-25 20:23           ` Karsten Blees
2014-06-25 20:53             ` Junio C Hamano
2014-06-26 17:37           ` Matthieu Moy
2014-06-26 19:00             ` Junio C Hamano
2014-06-26 19:19               ` Karsten Blees
2014-06-26 21:21                 ` Junio C Hamano
2014-06-27  8:19                   ` Karsten Blees
2014-06-27  8:19               ` Matthieu Moy
2014-06-27 17:13                 ` Junio C Hamano
2014-06-23 23:14   ` Junio C Hamano
2014-06-24 12:21     ` Tanay Abhra
2014-06-26 16:27       ` Matthieu Moy
2014-06-25 21:44   ` Karsten Blees
2014-06-26 16:43   ` Matthieu Moy
2014-06-23 10:11 ` [PATCH v3 3/3] test-config: add usage examples for non-callback query functions Tanay Abhra
2014-06-25 11:19   ` Eric Sunshine
2014-06-26  8:40     ` Tanay Abhra

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=53A82978.2010900@gmail.com \
    --to=tanayabh@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /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).