]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/test/rallocm.c
1 #define JEMALLOC_MANGLE
2 #include "jemalloc_test.h"
12 malloc_printf("Test begin\n");
19 pagesize
= (size_t)si
.dwPageSize
;
21 long result
= sysconf(_SC_PAGESIZE
);
23 pagesize
= (size_t)result
;
27 r
= allocm(&p
, &sz
, 42, 0);
28 if (r
!= ALLOCM_SUCCESS
) {
29 malloc_printf("Unexpected allocm() error\n");
34 r
= rallocm(&q
, &tsz
, sz
, 0, ALLOCM_NO_MOVE
);
35 if (r
!= ALLOCM_SUCCESS
)
36 malloc_printf("Unexpected rallocm() error\n");
38 malloc_printf("Unexpected object move\n");
40 malloc_printf("Unexpected size change: %zu --> %zu\n",
45 r
= rallocm(&q
, &tsz
, sz
, 5, ALLOCM_NO_MOVE
);
46 if (r
!= ALLOCM_SUCCESS
)
47 malloc_printf("Unexpected rallocm() error\n");
49 malloc_printf("Unexpected object move\n");
51 malloc_printf("Unexpected size change: %zu --> %zu\n",
56 r
= rallocm(&q
, &tsz
, sz
+ 5, 0, ALLOCM_NO_MOVE
);
57 if (r
!= ALLOCM_ERR_NOT_MOVED
)
58 malloc_printf("Unexpected rallocm() result\n");
60 malloc_printf("Unexpected object move\n");
62 malloc_printf("Unexpected size change: %zu --> %zu\n",
67 r
= rallocm(&q
, &tsz
, sz
+ 5, 0, 0);
68 if (r
!= ALLOCM_SUCCESS
)
69 malloc_printf("Unexpected rallocm() error\n");
71 malloc_printf("Expected object move\n");
73 malloc_printf("Expected size change: %zu --> %zu\n",
79 r
= rallocm(&q
, &tsz
, pagesize
*2, 0, 0);
80 if (r
!= ALLOCM_SUCCESS
)
81 malloc_printf("Unexpected rallocm() error\n");
83 malloc_printf("Expected object move\n");
85 malloc_printf("Expected size change: %zu --> %zu\n",
91 r
= rallocm(&q
, &tsz
, pagesize
*4, 0, 0);
92 if (r
!= ALLOCM_SUCCESS
)
93 malloc_printf("Unexpected rallocm() error\n");
95 malloc_printf("Expected size change: %zu --> %zu\n",
101 r
= rallocm(&q
, &tsz
, pagesize
*2, 0, ALLOCM_NO_MOVE
);
102 if (r
!= ALLOCM_SUCCESS
)
103 malloc_printf("Unexpected rallocm() error\n");
105 malloc_printf("Unexpected object move\n");
107 malloc_printf("Expected size change: %zu --> %zu\n",
112 r
= rallocm(&q
, &tsz
, pagesize
*4, 0, ALLOCM_NO_MOVE
);
113 if (r
!= ALLOCM_SUCCESS
)
114 malloc_printf("Unexpected rallocm() error\n");
116 malloc_printf("Unexpected object move\n");
118 malloc_printf("Expected size change: %zu --> %zu\n",
125 malloc_printf("Test end\n");