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

Re: [PATCH 3/6] Add functions for parsing integers with size suffixes

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 12, 2007, 13:07 UTC
Message-ID
<Pine.LNX.4.64.0707121404450.4516@racer.site>
In-Reply-To
<1184244952173-git-send-email-bdowning@lavos.net>
Hi,
On Thu, 12 Jul 2007, Brian Downing wrote:
> Split out the nnn{k,m,g} parsing code from git_config_int into 
> git_parse_long, so command-line parameters can enjoy the same 
> functionality.  Also add get_parse_ulong for unsigned values.
Nice!
Show 10 quoted lines
> +		if (!*end)
> +			*ret = val;
> +		else if (!strcasecmp(end, "k"))
> +			*ret = val * 1024;
> +		else if (!strcasecmp(end, "m"))
> +			*ret = val * 1024 * 1024;
> +		else if (!strcasecmp(end, "g"))
> +			*ret = val * 1024 * 1024 * 1024;
> +		else
> +			return 0;
This could be an own static function, like this:
unsigned long get_unit_factor(const char *end)
{
	if (!*end)
		return 1;
	if (!strcasecmp(end, "k"))
		return 1024;
	...
	error("Unknown unit: %s", end);
	return 1;
}
to avoid duplicated code.

Ciao, Dscho

Previous: Brian DowningNext: Brian Downing
Message 5 of 13 in “Pack window memory limit, take 2”
  1. 0/6 Pack window memory limit, take 2Brian Downing, Jul 12, 2007
  2. 1/6 Don't try to delta if target is much smaller than sourceBrian Downing, Jul 12, 2007
  3. 2/6 Support fetching the memory usage of a delta indexBrian Downing, Jul 12, 2007
  4. 3/6 Add functions for parsing integers with size suffixesBrian Downing, Jul 12, 2007
  5. Johannes SchindelinJul 12, 2007
  6. Add functions for parsing integers with size suffixesBrian Downing, Jul 12, 2007
  7. 4/6 Add pack-objects window memory usage limitBrian Downing, Jul 12, 2007
  8. Brian DowningJul 12, 2007
  9. Add pack-objects window memory usage limitBrian Downing, Jul 12, 2007
  10. 5/6 Add --window-memory option to git-repackBrian Downing, Jul 12, 2007
  11. 6/6 Add documentation for --window-memory, pack.windowMemoryBrian Downing, Jul 12, 2007
  12. Nicolas PitreJul 12, 2007
  13. Junio C HamanoJul 13, 2007

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.