git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/6] config: add 'git_config_string' to refactor string config variables.

From
Jeff King <peff@peff.net>
Date
Feb 16, 2008, 11:53 UTC
Message-ID
<20080216115310.GA11318@sigill.intra.peff.net>
In-Reply-To
<20080216060024.385fa360.chriscool@tuxfamily.org>
On Sat, Feb 16, 2008 at 06:00:24AM +0100, Christian Couder wrote:
Show 7 quoted lines
> +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').

-Peff
Previous: Christian CouderNext: Christian Couder
Message 2 of 4 in “config: add 'git_config_string' to refactor string config variables.”
  1. 2/6 config: add 'git_config_string' to refactor string config variables.Christian Couder, Feb 16, 2008
  2. Jeff KingFeb 16, 2008
  3. Christian CouderFeb 16, 2008
  4. Jeff KingFeb 16, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.