summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorDustin Sallings <dustin@spy.net>2009-03-14 23:57:38 -0700
committerDustin Sallings <dustin@spy.net>2009-03-19 01:52:53 -0700
commit7659ae1cb06c2aaa7ea491ef7a63740b0ef4abcf (patch)
tree7894820fb1335f88a73022109878068260cde5e0 /util.c
parent7b369ffb289ce1db2ee23a6b7acee1ecb910ecab (diff)
downloadmemcached-7659ae1cb06c2aaa7ea491ef7a63740b0ef4abcf.tar.gz
Reformatted util.c
Diffstat (limited to 'util.c')
-rw-r--r--util.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/util.c b/util.c
index ed2ec51..4de8199 100644
--- a/util.c
+++ b/util.c
@@ -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;
}