git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org, Junio Hamano <junkio@cox.net>,
	Pierre Habouzit <madcoder@debian.org>,
	Martin Koegler <mkoegler@auto.tuwien.ac.at>,
	Johannes Sixt <j.sixt@viscovery.net>
Subject: Re: [PATCH 2/6] config: add 'git_config_string' to refactor string config variables.
Date: Sat, 16 Feb 2008 19:21:42 +0100	[thread overview]
Message-ID: <200802161921.43346.chriscool@tuxfamily.org> (raw)
In-Reply-To: <20080216115310.GA11318@sigill.intra.peff.net>

Le samedi 16 février 2008, Jeff King a écrit :
> On Sat, Feb 16, 2008 at 06:00:24AM +0100, Christian Couder wrote:
> > +int git_config_string(const char **dest, const char *var, const char
> > *value) +{
> > +	if (!value)
> > +		return config_error_nonbool(var);
> > +	*dest = xstrdup(value);
> > +	return 0;
> > +}
>
> I'm not sure I see the point in using a 'const char *' as the
> destination. The string isn't inherently const, since it is allocated on
> the heap; callers are free to use it as they please (and are responsible
> for freeing it; while constness doesn't impact calling free() at a
> language level, I think that stylistically it is uncommon for a
> heap-allocated string to be stored as 'const').

Well, in many places where this function could be used the dest string is 
a "const char *" and in many other places it's a "char *", but it feels 
safer to try to promote the latter into the former (like I did in the 
following patches) rather than the other way around.

Christian.

  reply	other threads:[~2008-02-16 18:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-16  5:00 [PATCH 2/6] config: add 'git_config_string' to refactor string config variables Christian Couder
2008-02-16 11:53 ` Jeff King
2008-02-16 18:21   ` Christian Couder [this message]
2008-02-16 18:33     ` 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=200802161921.43346.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=junkio@cox.net \
    --cc=madcoder@debian.org \
    --cc=mkoegler@auto.tuwien.ac.at \
    --cc=peff@peff.net \
    /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).