diff --git a/ide/vs2017/mimalloc-test.vcxproj b/ide/vs2017/mimalloc-test.vcxproj
index 7976af56..8e61a97f 100644
--- a/ide/vs2017/mimalloc-test.vcxproj
+++ b/ide/vs2017/mimalloc-test.vcxproj
@@ -145,12 +145,7 @@
-
- AssemblyAndSourceCode
- AssemblyAndSourceCode
- AssemblyAndSourceCode
- AssemblyAndSourceCode
-
+
diff --git a/ide/vs2017/mimalloc-test.vcxproj.filters b/ide/vs2017/mimalloc-test.vcxproj.filters
index 9254f6c0..eb5e70b7 100644
--- a/ide/vs2017/mimalloc-test.vcxproj.filters
+++ b/ide/vs2017/mimalloc-test.vcxproj.filters
@@ -15,7 +15,7 @@
-
+
Source Files
diff --git a/ide/vs2017/mimalloc.sln b/ide/vs2017/mimalloc.sln
index f4860d93..aeab6b88 100644
--- a/ide/vs2017/mimalloc.sln
+++ b/ide/vs2017/mimalloc.sln
@@ -11,6 +11,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mimalloc-override", "mimall
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mimalloc-override-test", "mimalloc-override-test.vcxproj", "{FEF7868F-750E-4C21-A04D-22707CC66879}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mimalloc-test-stress", "mimalloc-test-stress.vcxproj", "{FEF7958F-750E-4C21-A04D-22707CC66878}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -51,6 +53,14 @@ Global
{FEF7868F-750E-4C21-A04D-22707CC66879}.Release|x64.Build.0 = Release|x64
{FEF7868F-750E-4C21-A04D-22707CC66879}.Release|x86.ActiveCfg = Release|Win32
{FEF7868F-750E-4C21-A04D-22707CC66879}.Release|x86.Build.0 = Release|Win32
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Debug|x64.ActiveCfg = Debug|x64
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Debug|x64.Build.0 = Debug|x64
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Debug|x86.ActiveCfg = Debug|Win32
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Debug|x86.Build.0 = Debug|Win32
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Release|x64.ActiveCfg = Release|x64
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Release|x64.Build.0 = Release|x64
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Release|x86.ActiveCfg = Release|Win32
+ {FEF7958F-750E-4C21-A04D-22707CC66878}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/ide/vs2017/mimalloc.vcxproj b/ide/vs2017/mimalloc.vcxproj
index 4a2069c6..86268f74 100644
--- a/ide/vs2017/mimalloc.vcxproj
+++ b/ide/vs2017/mimalloc.vcxproj
@@ -98,8 +98,9 @@
true
../../include
MI_DEBUG=3;%(PreprocessorDefinitions);
- Default
+ CompileAsCpp
false
+ stdcpp17
@@ -116,8 +117,9 @@
true
../../include
MI_DEBUG=3;%(PreprocessorDefinitions);
- Default
+ CompileAsCpp
false
+ stdcpp17
diff --git a/src/alloc-override.c b/src/alloc-override.c
index 5378850b..fba0c199 100644
--- a/src/alloc-override.c
+++ b/src/alloc-override.c
@@ -19,10 +19,6 @@ terms of the MIT license. A copy of the license can be found in the file
// Override system malloc
// ------------------------------------------------------
-#if defined(_MSC_VER)
-#pragma warning(disable:4273) // inconsistent dll linking
-#endif
-
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__MACH__)
// use aliasing to alias the exported function to one of our `mi_` functions
#if (defined(__GNUC__) && __GNUC__ >= 9)
@@ -62,6 +58,9 @@ terms of the MIT license. A copy of the license can be found in the file
MI_INTERPOSE_MI(strdup),
MI_INTERPOSE_MI(strndup)
};
+#elif defined(_MSC_VER)
+ // cannot override malloc unless using a dll.
+ // we just override new/delete which does work in a static library.
#else
// On all other systems forward to our API
void* malloc(size_t size) mi_attr_noexcept MI_FORWARD1(mi_malloc, size);
@@ -94,7 +93,7 @@ terms of the MIT license. A copy of the license can be found in the file
void* operator new (std::size_t n, const std::nothrow_t& tag) noexcept { UNUSED(tag); return mi_new_nothrow(n); }
void* operator new[](std::size_t n, const std::nothrow_t& tag) noexcept { UNUSED(tag); return mi_new_nothrow(n); }
- #if (__cplusplus >= 201402L)
+ #if (__cplusplus >= 201402L || _MSC_VER >= 1916)
void operator delete (void* p, std::size_t n) MI_FORWARD02(mi_free_size,p,n);
void operator delete[](void* p, std::size_t n) MI_FORWARD02(mi_free_size,p,n);
#endif
diff --git a/src/memory.c b/src/memory.c
index 74a9628c..e7d1887e 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -105,7 +105,7 @@ static size_t mi_good_commit_size(size_t size) {
}
// Return if a pointer points into a region reserved by us.
-bool mi_is_in_heap_region(const void* p) {
+bool mi_is_in_heap_region(const void* p) mi_attr_noexcept {
size_t count = mi_atomic_read(®ions_count);
for (size_t i = 0; i < count; i++) {
uint8_t* start = (uint8_t*)mi_atomic_read_ptr(®ions[i].start);
diff --git a/test/main-override.cpp b/test/main-override.cpp
index 3c192fe3..ec7854a2 100644
--- a/test/main-override.cpp
+++ b/test/main-override.cpp
@@ -43,8 +43,7 @@ int main() {
delete t;
t = new (std::nothrow) Test(42);
delete t;
- free(p);
- return 0;
+ return 0;
}
class Static {