Skip to content

Commit

Permalink
safe_strou?ll functions should operate on u?int64_t types.
Browse files Browse the repository at this point in the history
long long and unsigned long long are interchangeable in most places,
but apparently not my 64-bit ubuntu 8.10 box.
  • Loading branch information
dustin committed Mar 19, 2009
1 parent 24fda0f commit a977b55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal_tests.c
Expand Up @@ -10,7 +10,7 @@ static void test_safe_strtoull(void);
static void test_safe_strtoll(void);

static void test_safe_strtoull() {
unsigned long long val;
uint64_t val;
assert(safe_strtoull("123", &val));
assert(val == 123);
assert(safe_strtoull("+123", &val));
Expand All @@ -27,7 +27,7 @@ static void test_safe_strtoull() {
}

static void test_safe_strtoll() {
long long val;
int64_t val;
assert(safe_strtoll("123", &val));
assert(val == 123);
assert(safe_strtoll("+123", &val));
Expand Down
4 changes: 2 additions & 2 deletions util.c
Expand Up @@ -7,7 +7,7 @@

#include "memcached.h"

bool safe_strtoull(const char *str, unsigned long long *out) {
bool safe_strtoull(const char *str, uint64_t *out) {
assert(out != NULL);
errno = 0;
*out = 0;
Expand All @@ -30,7 +30,7 @@ bool safe_strtoull(const char *str, unsigned long long *out) {
return false;
}

bool safe_strtoll(const char *str, long long *out) {
bool safe_strtoll(const char *str, int64_t *out) {
assert(out != NULL);
errno = 0;
*out = 0;
Expand Down
6 changes: 2 additions & 4 deletions util.h
Expand Up @@ -7,7 +7,5 @@
*
* returns true if conversion succeeded.
*/
bool safe_strtoull(const char *str, unsigned long long *out);
bool safe_strtoll(const char *str, long long *out);


bool safe_strtoull(const char *str, uint64_t *out);
bool safe_strtoll(const char *str, int64_t *out);

0 comments on commit a977b55

Please sign in to comment.