forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start of the incr fix, rearranges a bunch, adds util, tests, etc
- Loading branch information
Showing
7 changed files
with
78 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ memcached-*.tar.gz | |
doc/protocol-binary-range.txt | ||
doc/protocol-binary.txt | ||
/sizes | ||
/internal_tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "memcached.h" | ||
|
||
/* | ||
* This file contains global variables shared across the rest of the | ||
* memcached codebase. These were originally in memcached.c but had | ||
* to be removed to make the rest of the object files linkable into | ||
* the test infrastructure. | ||
* | ||
*/ | ||
|
||
/* | ||
* We keep the current time of day in a global variable that's updated by a | ||
* timer event. This saves us a bunch of time() system calls (we really only | ||
* need to get the time once a second, whereas there can be tens of thousands | ||
* of requests a second) and allows us to use server-start-relative timestamps | ||
* rather than absolute UNIX timestamps, a space savings on systems where | ||
* sizeof(time_t) > sizeof(unsigned int). | ||
*/ | ||
volatile rel_time_t current_time; | ||
|
||
/** exported globals **/ | ||
struct stats stats; | ||
struct settings settings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
|
||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include "memcached.h" | ||
|
||
int main(int argc, char **argv) { | ||
unsigned long long ull; | ||
assert(safe_strtoull("123", &ull)); | ||
assert(ull == 123); | ||
|
||
// Empty: | ||
assert(!safe_strtoull("", &ull)); | ||
|
||
// Bogus: | ||
assert(!safe_strtoull("123BOGUS", &ull)); | ||
|
||
printf("OK.\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* str a NULL-terminated base decimal 10 unsigned integer | ||
* out out parameter, if conversion succeeded | ||
* | ||
* returns true if conversion succeeded. | ||
*/ | ||
bool safe_strtoull(const char *str, unsigned long long *out); | ||
|