summaryrefslogtreecommitdiff
path: root/examples/redis-unstable/deps/jemalloc/test/unit/zero_realloc_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/unit/zero_realloc_alloc.c')
-rw-r--r--examples/redis-unstable/deps/jemalloc/test/unit/zero_realloc_alloc.c48
1 files changed, 0 insertions, 48 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/unit/zero_realloc_alloc.c b/examples/redis-unstable/deps/jemalloc/test/unit/zero_realloc_alloc.c
deleted file mode 100644
index 65e07bd..0000000
--- a/examples/redis-unstable/deps/jemalloc/test/unit/zero_realloc_alloc.c
+++ /dev/null
@@ -1,48 +0,0 @@
1#include "test/jemalloc_test.h"
2
3static uint64_t
4allocated() {
5 if (!config_stats) {
6 return 0;
7 }
8 uint64_t allocated;
9 size_t sz = sizeof(allocated);
10 expect_d_eq(mallctl("thread.allocated", (void *)&allocated, &sz, NULL,
11 0), 0, "Unexpected mallctl failure");
12 return allocated;
13}
14
15static uint64_t
16deallocated() {
17 if (!config_stats) {
18 return 0;
19 }
20 uint64_t deallocated;
21 size_t sz = sizeof(deallocated);
22 expect_d_eq(mallctl("thread.deallocated", (void *)&deallocated, &sz,
23 NULL, 0), 0, "Unexpected mallctl failure");
24 return deallocated;
25}
26
27TEST_BEGIN(test_realloc_alloc) {
28 void *ptr = mallocx(1, 0);
29 expect_ptr_not_null(ptr, "Unexpected mallocx error");
30 uint64_t allocated_before = allocated();
31 uint64_t deallocated_before = deallocated();
32 ptr = realloc(ptr, 0);
33 uint64_t allocated_after = allocated();
34 uint64_t deallocated_after = deallocated();
35 if (config_stats) {
36 expect_u64_lt(allocated_before, allocated_after,
37 "Unexpected stats change");
38 expect_u64_lt(deallocated_before, deallocated_after,
39 "Unexpected stats change");
40 }
41 dallocx(ptr, 0);
42}
43TEST_END
44int
45main(void) {
46 return test(
47 test_realloc_alloc);
48}