]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/test/mremap.c
7 #define JEMALLOC_MANGLE
8 #include "jemalloc_test.h"
14 size_t sz
, lg_chunk
, chunksize
, i
;
17 fprintf(stderr
, "Test begin\n");
19 sz
= sizeof(lg_chunk
);
20 if ((err
= JEMALLOC_P(mallctl
)("opt.lg_chunk", &lg_chunk
, &sz
, NULL
,
22 assert(err
!= ENOENT
);
23 fprintf(stderr
, "%s(): Error in mallctl(): %s\n", __func__
,
28 chunksize
= ((size_t)1U) << lg_chunk
;
30 p
= (char *)malloc(chunksize
);
32 fprintf(stderr
, "malloc(%zu) --> %p\n", chunksize
, p
);
36 memset(p
, 'a', chunksize
);
38 q
= (char *)realloc(p
, chunksize
* 2);
40 fprintf(stderr
, "realloc(%p, %zu) --> %p\n", p
, chunksize
* 2,
45 for (i
= 0; i
< chunksize
; i
++) {
51 q
= (char *)realloc(p
, chunksize
);
53 fprintf(stderr
, "realloc(%p, %zu) --> %p\n", p
, chunksize
, q
);
57 for (i
= 0; i
< chunksize
; i
++) {
65 fprintf(stderr
, "Test end\n");