diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-26 20:34:26 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-09-03 20:03:47 +0000 |
commit | 6872c14e1a02445d945623ee6e85230c5d7ecbce (patch) | |
tree | 30d90b93445976e56b96946b6e87b764eddd48a8 /auto_tests | |
parent | d296490a742b226fc17a71cf96ab73fc16719b20 (diff) |
Avoid use of global mutable state in mono_time on win32.
This uses a trick to get read-write access to `this` from a `const`
member function, similar to C++ `mutable`, but uglier.
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/dht_test.c | 5 | ||||
-rw-r--r-- | auto_tests/run_auto_test.h | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c index 232b7d95..f9c09dd5 100644 --- a/auto_tests/dht_test.c +++ b/auto_tests/dht_test.c | |||
@@ -600,9 +600,10 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port) | |||
600 | 600 | ||
601 | #define NUM_DHT_FRIENDS 20 | 601 | #define NUM_DHT_FRIENDS 20 |
602 | 602 | ||
603 | static uint64_t get_clock_callback(void *user_data) | 603 | static uint64_t get_clock_callback(Mono_Time *mono_time, void *user_data) |
604 | { | 604 | { |
605 | return *(uint64_t *)user_data; | 605 | const uint64_t *clock = (const uint64_t *)user_data; |
606 | return *clock; | ||
606 | } | 607 | } |
607 | 608 | ||
608 | static void test_DHT_test(void) | 609 | static void test_DHT_test(void) |
diff --git a/auto_tests/run_auto_test.h b/auto_tests/run_auto_test.h index 602ad524..bcbfed55 100644 --- a/auto_tests/run_auto_test.h +++ b/auto_tests/run_auto_test.h | |||
@@ -42,9 +42,10 @@ static void iterate_all_wait(uint32_t tox_count, Tox **toxes, State *state, uint | |||
42 | c_sleep(20); | 42 | c_sleep(20); |
43 | } | 43 | } |
44 | 44 | ||
45 | static uint64_t get_state_clock_callback(void *user_data) | 45 | static uint64_t get_state_clock_callback(Mono_Time *mono_time, void *user_data) |
46 | { | 46 | { |
47 | return ((State *)user_data)->clock; | 47 | const State *state = (const State *)user_data; |
48 | return state->clock; | ||
48 | } | 49 | } |
49 | 50 | ||
50 | static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *state)) | 51 | static void run_auto_test(uint32_t tox_count, void test(Tox **toxes, State *state)) |