mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 23:39:31 +03:00
extend override test on windows
This commit is contained in:
parent
6bfb1c656c
commit
2c34250f43
2 changed files with 40 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
// Issue #981: test overriding allocation in a DLL that is compiled independent of mimalloc.
|
// Issue #981: test overriding allocation in a DLL that is compiled independent of mimalloc.
|
||||||
// This is imported by the `mimalloc-test-override` project.
|
// This is imported by the `mimalloc-test-override` project.
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
#include "main-override-dep.h"
|
#include "main-override-dep.h"
|
||||||
|
|
||||||
std::string TestAllocInDll::GetString()
|
std::string TestAllocInDll::GetString()
|
||||||
|
@ -10,6 +11,41 @@ std::string TestAllocInDll::GetString()
|
||||||
const char* t = "test";
|
const char* t = "test";
|
||||||
memcpy(test, t, 4);
|
memcpy(test, t, 4);
|
||||||
std::string r = test;
|
std::string r = test;
|
||||||
|
std::cout << "override-dep: GetString: " << r << "\n";
|
||||||
delete[] test;
|
delete[] test;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Static {
|
||||||
|
private:
|
||||||
|
void* p;
|
||||||
|
public:
|
||||||
|
Static() {
|
||||||
|
printf("override-dep: static constructor\n");
|
||||||
|
p = malloc(64);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
~Static() {
|
||||||
|
free(p);
|
||||||
|
printf("override-dep: static destructor\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static Static s = Static();
|
||||||
|
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
BOOL WINAPI DllMain(HINSTANCE module, DWORD reason, LPVOID reserved) {
|
||||||
|
(void)(reserved);
|
||||||
|
(void)(module);
|
||||||
|
if (reason==DLL_PROCESS_ATTACH) {
|
||||||
|
printf("override-dep: dll attach\n");
|
||||||
|
}
|
||||||
|
else if (reason==DLL_PROCESS_DETACH) {
|
||||||
|
printf("override-dep: dll detach\n");
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void test_thread_local(); // issue #944
|
||||||
static void test_mixed1(); // issue #942
|
static void test_mixed1(); // issue #942
|
||||||
static void test_stl_allocators();
|
static void test_stl_allocators();
|
||||||
|
|
||||||
#if x_WIN32
|
#if _WIN32
|
||||||
#include "main-override-dep.h"
|
#include "main-override-dep.h"
|
||||||
static void test_dep(); // issue #981: test overriding in another DLL
|
static void test_dep(); // issue #981: test overriding in another DLL
|
||||||
#else
|
#else
|
||||||
|
@ -145,11 +145,12 @@ static bool test_stl_allocator1() {
|
||||||
struct some_struct { int i; int j; double z; };
|
struct some_struct { int i; int j; double z; };
|
||||||
|
|
||||||
|
|
||||||
#if x_WIN32
|
#if _WIN32
|
||||||
static void test_dep()
|
static void test_dep()
|
||||||
{
|
{
|
||||||
TestAllocInDll t;
|
TestAllocInDll t;
|
||||||
std::string s = t.GetString();
|
std::string s = t.GetString();
|
||||||
|
std::cout << "test_dep GetString: " << s << "\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue