mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 11:34:38 +03:00
merge from dev
This commit is contained in:
commit
d7c273e5cd
10 changed files with 456 additions and 33 deletions
15
test/main-override-dep.cpp
Normal file
15
test/main-override-dep.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Issue #981: test overriding allocation in a DLL that is compiled independent of mimalloc.
|
||||
// This is imported by the `mimalloc-test-override` project.
|
||||
#include <string>
|
||||
#include "main-override-dep.h"
|
||||
|
||||
std::string TestAllocInDll::GetString()
|
||||
{
|
||||
char* test = new char[128];
|
||||
memset(test, 0, 128);
|
||||
const char* t = "test";
|
||||
memcpy(test, t, 4);
|
||||
std::string r = test;
|
||||
delete[] test;
|
||||
return r;
|
||||
}
|
11
test/main-override-dep.h
Normal file
11
test/main-override-dep.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
// Issue #981: test overriding allocation in a DLL that is compiled independent of mimalloc.
|
||||
// This is imported by the `mimalloc-test-override` project.
|
||||
|
||||
#include <string>
|
||||
|
||||
class TestAllocInDll
|
||||
{
|
||||
public:
|
||||
__declspec(dllexport) std::string GetString();
|
||||
};
|
|
@ -9,16 +9,11 @@
|
|||
#include <vector>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
|
||||
#include <thread>
|
||||
//#include <mimalloc.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <mimalloc-new-delete.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
static void msleep(unsigned long msecs) { Sleep(msecs); }
|
||||
#else
|
||||
|
@ -42,11 +37,19 @@ static void test_thread_local(); // issue #944
|
|||
static void test_mixed1(); // issue #942
|
||||
static void test_stl_allocators();
|
||||
|
||||
#if _WIN32
|
||||
#include "main-override-dep.h"
|
||||
static void test_dep(); // issue #981: test overriding in another DLL
|
||||
#else
|
||||
static void test_dep() { };
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
mi_stats_reset(); // ignore earlier allocations
|
||||
various_tests();
|
||||
test_mixed1();
|
||||
|
||||
test_dep();
|
||||
|
||||
//test_std_string();
|
||||
//test_thread_local();
|
||||
|
@ -139,6 +142,16 @@ static bool test_stl_allocator1() {
|
|||
|
||||
struct some_struct { int i; int j; double z; };
|
||||
|
||||
|
||||
#if _WIN32
|
||||
static void test_dep()
|
||||
{
|
||||
TestAllocInDll t;
|
||||
std::string s = t.GetString();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static bool test_stl_allocator2() {
|
||||
std::vector<some_struct, mi_stl_allocator<some_struct> > vec;
|
||||
vec.push_back(some_struct());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue