expect_d_eq(mallctl("arenas.create", &arena1, &sz, NULL, 0), 0,
"Failed to create arena");
void *huge = mallocx(HUGE_SZ, MALLOCX_ARENA(arena1));
expect_ptr_not_null(huge, "Fail to allocate huge size");
expect_d_eq(mallctl("arenas.lookup", &arena2, &sz, &huge,
sizeof(huge)), 0, "Unexpected mallctl() failure");
expect_u_eq(arena1, arena2, "Wrong arena used for mallocx");
dallocx(huge, MALLOCX_ARENA(arena1));
void *huge2 = mallocx(HUGE_SZ, 0);
expect_ptr_not_null(huge, "Fail to allocate huge size");
expect_d_eq(mallctl("arenas.lookup", &arena2, &sz, &huge2,
sizeof(huge2)), 0, "Unexpected mallctl() failure");
expect_u_ne(arena1, arena2,
"Huge allocation should not come from the manual arena.");
expect_u_ne(arena2, 0,
"Huge allocation should not come from the arena 0.");
dallocx(huge2, 0);
}
TEST_END
ptr = mallocx(SMALL_SZ, MALLOCX_TCACHE_NONE);
expect_ptr_not_null(ptr, "Fail to allocate small size");
expect_d_eq(mallctl("arenas.lookup", &arena2, &sz, &ptr,
sizeof(ptr)), 0, "Unexpected mallctl() failure");
expect_u_ne(arena1, arena2,
"Huge and small should be from different arenas");
dallocx(ptr, 0);
}
TEST_END
int
main(void) {
return test(
huge_allocation,
huge_mallocx,
huge_bind_thread);
}