diff options
author | Dustin Sallings <dustin@spy.net> | 2009-03-14 23:57:38 -0700 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2009-03-19 01:52:53 -0700 |
commit | 7659ae1cb06c2aaa7ea491ef7a63740b0ef4abcf (patch) | |
tree | 7894820fb1335f88a73022109878068260cde5e0 /util.c | |
parent | 7b369ffb289ce1db2ee23a6b7acee1ecb910ecab (diff) | |
download | memcached-7659ae1cb06c2aaa7ea491ef7a63740b0ef4abcf.tar.gz |
Reformatted util.c
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 57 |
1 files changed, 29 insertions, 28 deletions
@@ -8,38 +8,39 @@ #include "memcached.h" bool safe_strtoull(const char *str, unsigned long long *out) { - assert(out != NULL); - errno = 0; - *out = 0; - char *endptr; - unsigned long long ull = strtoull(str, &endptr, 10); - if (errno == ERANGE) - return false; - if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { - if ((long long) ull < 0) { - /* only check for negative signs in the uncommon case when the unsigned - * number is so big that it's negative as a signed number. */ - if (strchr(str, '-') != NULL) { + assert(out != NULL); + errno = 0; + *out = 0; + char *endptr; + unsigned long long ull = strtoull(str, &endptr, 10); + if (errno == ERANGE) return false; - } + if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { + if ((long long) ull < 0) { + /* only check for negative signs in the uncommon case when + * the unsigned number is so big that it's negative as a + * signed number. */ + if (strchr(str, '-') != NULL) { + return false; + } + } + *out = ull; + return true; } - *out = ull; - return true; - } - return false; + return false; } bool safe_strtoll(const char *str, long long *out) { - assert(out != NULL); - errno = 0; - *out = 0; - char *endptr; - long long ll = strtoll(str, &endptr, 10); - if (errno == ERANGE) + assert(out != NULL); + errno = 0; + *out = 0; + char *endptr; + long long ll = strtoll(str, &endptr, 10); + if (errno == ERANGE) + return false; + if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { + *out = ll; + return true; + } return false; - if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { - *out = ll; - return true; - } - return false; } |