Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105792
b: refs/heads/master
c: fd19382
h: refs/heads/master
v: v3
  • Loading branch information
Robert P. J. Day authored and Linus Torvalds committed Jul 25, 2008
1 parent 899a257 commit a9aeabe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cb345d7352aa9e692ef4b83c41d3e6e1cdb2f846
refs/heads/master: fd193829744bc77392395cf8f47889235c97f0a3
16 changes: 11 additions & 5 deletions trunk/lib/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ char *get_options(const char *str, int nints, int *ints)
/**
* memparse - parse a string with mem suffixes into a number
* @ptr: Where parse begins
* @retptr: (output) Pointer to next char after parse completes
* @retptr: (output) Optional pointer to next char after parse completes
*
* Parses a string into a number. The number stored at @ptr is
* potentially suffixed with %K (for kilobytes, or 1024 bytes),
Expand All @@ -126,11 +126,13 @@ char *get_options(const char *str, int nints, int *ints)
* megabyte, or one gigabyte, respectively.
*/

unsigned long long memparse (char *ptr, char **retptr)
unsigned long long memparse(char *ptr, char **retptr)
{
unsigned long long ret = simple_strtoull (ptr, retptr, 0);
char *endptr; /* local pointer to end of parsed string */

switch (**retptr) {
unsigned long long ret = simple_strtoull(ptr, &endptr, 0);

switch (*endptr) {
case 'G':
case 'g':
ret <<= 10;
Expand All @@ -140,10 +142,14 @@ unsigned long long memparse (char *ptr, char **retptr)
case 'K':
case 'k':
ret <<= 10;
(*retptr)++;
endptr++;
default:
break;
}

if (retptr)
*retptr = endptr;

return ret;
}

Expand Down

0 comments on commit a9aeabe

Please sign in to comment.