aboutsummaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/jemalloc/test/unit/zero_reallocs.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/unit/zero_reallocs.c')
-rw-r--r--examples/redis-unstable/deps/jemalloc/test/unit/zero_reallocs.c40
1 files changed, 0 insertions, 40 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/unit/zero_reallocs.c b/examples/redis-unstable/deps/jemalloc/test/unit/zero_reallocs.c
deleted file mode 100644
index 66c7a40..0000000
--- a/examples/redis-unstable/deps/jemalloc/test/unit/zero_reallocs.c
+++ /dev/null
@@ -1,40 +0,0 @@
1#include "test/jemalloc_test.h"
2
3static size_t
4zero_reallocs() {
5 if (!config_stats) {
6 return 0;
7 }
8 size_t count = 12345;
9 size_t sz = sizeof(count);
10
11 expect_d_eq(mallctl("stats.zero_reallocs", (void *)&count, &sz,
12 NULL, 0), 0, "Unexpected mallctl failure");
13 return count;
14}
15
16TEST_BEGIN(test_zero_reallocs) {
17 test_skip_if(!config_stats);
18
19 for (size_t i = 0; i < 100; ++i) {
20 void *ptr = mallocx(i * i + 1, 0);
21 expect_ptr_not_null(ptr, "Unexpected mallocx error");
22 size_t count = zero_reallocs();
23 expect_zu_eq(i, count, "Incorrect zero realloc count");
24 ptr = realloc(ptr, 0);
25 expect_ptr_null(ptr, "Realloc didn't free");
26 count = zero_reallocs();
27 expect_zu_eq(i + 1, count, "Realloc didn't adjust count");
28 }
29}
30TEST_END
31
32int
33main(void) {
34 /*
35 * We expect explicit counts; reentrant tests run multiple times, so
36 * counts leak across runs.
37 */
38 return test_no_reentrancy(
39 test_zero_reallocs);
40}