mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-05 23:19:31 +03:00
add test for #445
This commit is contained in:
parent
076f815cec
commit
a3cf23c19f
1 changed files with 14 additions and 7 deletions
|
@ -34,6 +34,7 @@ void various_tests();
|
||||||
void test_mt_shutdown();
|
void test_mt_shutdown();
|
||||||
void fail_aslr(); // issue #372
|
void fail_aslr(); // issue #372
|
||||||
void tsan_numa_test(); // issue #414
|
void tsan_numa_test(); // issue #414
|
||||||
|
void strdup_test(); // issue #445
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
mi_stats_reset(); // ignore earlier allocations
|
mi_stats_reset(); // ignore earlier allocations
|
||||||
|
@ -43,6 +44,7 @@ int main() {
|
||||||
padding_shrink();
|
padding_shrink();
|
||||||
various_tests();
|
various_tests();
|
||||||
tsan_numa_test();
|
tsan_numa_test();
|
||||||
|
strdup_test();
|
||||||
|
|
||||||
//test_mt_shutdown();
|
//test_mt_shutdown();
|
||||||
//fail_aslr();
|
//fail_aslr();
|
||||||
|
@ -74,18 +76,13 @@ void various_tests() {
|
||||||
p1 = malloc(8);
|
p1 = malloc(8);
|
||||||
char* s = mi_strdup("hello\n");
|
char* s = mi_strdup("hello\n");
|
||||||
|
|
||||||
//char* s = _strdup("hello\n");
|
|
||||||
//char* buf = NULL;
|
|
||||||
//size_t len;
|
|
||||||
//_dupenv_s(&buf,&len,"MIMALLOC_VERBOSE");
|
|
||||||
//mi_free(buf);
|
|
||||||
|
|
||||||
mi_free(p2);
|
mi_free(p2);
|
||||||
p2 = malloc(16);
|
p2 = malloc(16);
|
||||||
p1 = realloc(p1, 32);
|
p1 = realloc(p1, 32);
|
||||||
free(p1);
|
free(p1);
|
||||||
free(p2);
|
free(p2);
|
||||||
mi_free(s);
|
mi_free(s);
|
||||||
|
|
||||||
Test* t = new Test(42);
|
Test* t = new Test(42);
|
||||||
delete t;
|
delete t;
|
||||||
t = new (std::nothrow) Test(42);
|
t = new (std::nothrow) Test(42);
|
||||||
|
@ -125,7 +122,17 @@ bool test_stl_allocator2() {
|
||||||
return vec.size() == 0;
|
return vec.size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue 445
|
||||||
|
static void strdup_test() {
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
char* s = _strdup("hello\n");
|
||||||
|
char* buf = NULL;
|
||||||
|
size_t len;
|
||||||
|
_dupenv_s(&buf, &len, "MIMALLOC_VERBOSE");
|
||||||
|
mi_free(buf);
|
||||||
|
mi_free(s);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Issue #202
|
// Issue #202
|
||||||
void heap_no_delete_worker() {
|
void heap_no_delete_worker() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue