merge segment_init refactoring from dev

This commit is contained in:
Daan Leijen 2022-11-22 19:03:26 -08:00
commit 85b5fa11bc
5 changed files with 302 additions and 131 deletions

View file

@ -38,6 +38,8 @@ static void tsan_numa_test(); // issue #414
static void strdup_test(); // issue #445
static void bench_alloc_large(void); // issue #xxx
static void test_stl_allocators();
int main() {
mi_stats_reset(); // ignore earlier allocations
@ -50,6 +52,8 @@ int main() {
tsan_numa_test();
strdup_test();
test_stl_allocators();
test_mt_shutdown();
//fail_aslr();
bench_alloc_large();
@ -127,6 +131,43 @@ static bool test_stl_allocator2() {
return vec.size() == 0;
}
static bool test_stl_allocator3() {
std::vector<int, mi_heap_stl_allocator<int> > vec;
vec.push_back(1);
vec.pop_back();
return vec.size() == 0;
}
static bool test_stl_allocator4() {
std::vector<some_struct, mi_heap_stl_allocator<some_struct> > vec;
vec.push_back(some_struct());
vec.pop_back();
return vec.size() == 0;
}
static bool test_stl_allocator5() {
std::vector<int, mi_heap_destroy_stl_allocator<int> > vec;
vec.push_back(1);
vec.pop_back();
return vec.size() == 0;
}
static bool test_stl_allocator6() {
std::vector<some_struct, mi_heap_destroy_stl_allocator<some_struct> > vec;
vec.push_back(some_struct());
vec.pop_back();
return vec.size() == 0;
}
static void test_stl_allocators() {
test_stl_allocator1();
test_stl_allocator2();
test_stl_allocator3();
test_stl_allocator4();
test_stl_allocator5();
test_stl_allocator6();
}
// issue 445
static void strdup_test() {
#ifdef _MSC_VER