diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +#include <stdlib.h> +#include <assert.h> + +#include "memcached.h" + +bool safe_strtoull(const char *str, unsigned long long *out) { + assert(out != NULL); + *out = 0; + char *endptr; + unsigned long long ull = strtoull(str, &endptr, 10); + if (*endptr == '\0' && endptr != str) { + *out = ull; + return true; + } + return false; +} |