]>
git.proxmox.com Git - rustc.git/blob - src/jemalloc/test/unit/zero.c
1 #include "test/jemalloc_test.h"
4 const char *malloc_conf
=
5 "abort:false,junk:false,zero:true,redzone:false,quarantine:0";
9 test_zero(size_t sz_min
, size_t sz_max
)
12 size_t sz_prev
, sz
, i
;
15 s
= (char *)mallocx(sz_min
, 0);
16 assert_ptr_not_null((void *)s
, "Unexpected mallocx() failure");
18 for (sz
= sallocx(s
, 0); sz
<= sz_max
;
19 sz_prev
= sz
, sz
= sallocx(s
, 0)) {
21 assert_c_eq(s
[0], 'a',
22 "Previously allocated byte %zu/%zu is corrupted",
24 assert_c_eq(s
[sz_prev
-1], 'a',
25 "Previously allocated byte %zu/%zu is corrupted",
29 for (i
= sz_prev
; i
< sz
; i
++) {
30 assert_c_eq(s
[i
], 0x0,
31 "Newly allocated byte %zu/%zu isn't zero-filled",
36 if (xallocx(s
, sz
+1, 0, 0) == sz
) {
37 s
= (char *)rallocx(s
, sz
+1, 0);
38 assert_ptr_not_null((void *)s
,
39 "Unexpected rallocx() failure");
46 TEST_BEGIN(test_zero_small
)
49 test_skip_if(!config_fill
);
50 test_zero(1, SMALL_MAXCLASS
-1);
54 TEST_BEGIN(test_zero_large
)
57 test_skip_if(!config_fill
);
58 test_zero(SMALL_MAXCLASS
+1, large_maxclass
);
62 TEST_BEGIN(test_zero_huge
)
65 test_skip_if(!config_fill
);
66 test_zero(large_maxclass
+1, chunksize
*2);