Skip to content

Commit 29e7a3e

Browse files
committed
Merge branch 'dev' into dev3
2 parents 5008841 + 7965fd8 commit 29e7a3e

5 files changed

Lines changed: 22 additions & 14 deletions

File tree

ide/vs2022/mimalloc-override-static-lib.vcxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
<CompileAs>CompileAsCpp</CompileAs>
179179
<SupportJustMyCode>false</SupportJustMyCode>
180180
<LanguageStandard>stdcpp20</LanguageStandard>
181-
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
181+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
182182
</ClCompile>
183183
<Lib>
184184
<AdditionalLibraryDirectories>
@@ -226,7 +226,7 @@
226226
<CompileAs>CompileAsCpp</CompileAs>
227227
<SupportJustMyCode>false</SupportJustMyCode>
228228
<LanguageStandard>stdcpp20</LanguageStandard>
229-
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
229+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
230230
</ClCompile>
231231
<PostBuildEvent>
232232
<Command>
@@ -254,7 +254,7 @@
254254
<CompileAs>CompileAsCpp</CompileAs>
255255
<SupportJustMyCode>false</SupportJustMyCode>
256256
<LanguageStandard>stdcpp20</LanguageStandard>
257-
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
257+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
258258
</ClCompile>
259259
<PostBuildEvent>
260260
<Command>

ide/vs2022/mimalloc-test-override-static.vcxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
<ConformanceMode>true</ConformanceMode>
165165
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
166166
<LanguageStandard>stdcpp17</LanguageStandard>
167-
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
167+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
168168
<PreprocessorDefinitions>MI_DEBUG=3;;MI_MALLOC_OVERRIDE</PreprocessorDefinitions>
169169
</ClCompile>
170170
<Link>
@@ -194,7 +194,7 @@
194194
<ConformanceMode>true</ConformanceMode>
195195
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
196196
<LanguageStandard>stdcpp17</LanguageStandard>
197-
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
197+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
198198
<PreprocessorDefinitions>MI_DEBUG=3;_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions);MI_MALLOC_OVERRIDE</PreprocessorDefinitions>
199199
</ClCompile>
200200
<Link>
@@ -209,7 +209,7 @@
209209
<ConformanceMode>true</ConformanceMode>
210210
<AdditionalIncludeDirectories>..\..\include</AdditionalIncludeDirectories>
211211
<LanguageStandard>stdcpp17</LanguageStandard>
212-
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
212+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
213213
<PreprocessorDefinitions>MI_DEBUG=3;_AMD64_;_ARM64EC_;%(ClCompile.PreprocessorDefinitions);MI_MALLOC_OVERRIDE</PreprocessorDefinitions>
214214
</ClCompile>
215215
<Link>

include/mimalloc/track.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ defined, undefined, or not accessible at all:
8484

8585
#include "../src/prim/windows/etw.h"
8686

87-
#define mi_track_init() EventRegistermicrosoft_windows_mimalloc();
87+
#define mi_track_init() EventRegistermicrosoft_windows_mimalloc()
88+
#define mi_track_done() EventUnregistermicrosoft_windows_mimalloc()
8889
#define mi_track_malloc_size(p,reqsize,size,zero) EventWriteETW_MI_ALLOC((UINT64)(p), size)
8990
#define mi_track_free_size(p,size) EventWriteETW_MI_FREE((UINT64)(p), size)
9091

@@ -115,6 +116,10 @@ defined, undefined, or not accessible at all:
115116
#define mi_track_init()
116117
#endif
117118

119+
#ifndef mi_track_done
120+
#define mi_track_done()
121+
#endif
122+
118123
#ifndef mi_track_mem_defined
119124
#define mi_track_mem_defined(p,size)
120125
#endif

src/alloc-override.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ typedef void* mi_nothrow_t;
9292
MI_INTERPOSE_FUN(vfree,mi_cfree),
9393
#endif
9494
};
95-
MI_INTERPOSE_DECLS(_mi_interposes_10_7) __OSX_AVAILABLE(10.7) = {
96-
MI_INTERPOSE_MI(strndup),
97-
};
98-
MI_INTERPOSE_DECLS(_mi_interposes_10_15) __OSX_AVAILABLE(10.15) = {
99-
MI_INTERPOSE_MI(aligned_alloc),
100-
};
95+
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
96+
MI_INTERPOSE_DECLS(_mi_interposes_10_7) = { MI_INTERPOSE_MI(strndup) };
97+
#endif
98+
#if defined(MAC_OS_X_VERSION_10_15) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15)
99+
MI_INTERPOSE_DECLS(_mi_interposes_10_15) = { MI_INTERPOSE_MI(aligned_alloc) };
100+
#endif
101101

102102
#ifdef __cplusplus
103103
extern "C" {
@@ -358,7 +358,7 @@ void cfree(void* p) { mi_free(p); }
358358
void* pvalloc(size_t size) { return mi_pvalloc(size); }
359359
void* memalign(size_t alignment, size_t size) { return mi_memalign(alignment, size); }
360360
#if !defined(_WIN32)
361-
void* _aligned_malloc(size_t alignment, size_t size) { return mi_aligned_alloc(alignment, size); }
361+
void* _aligned_malloc(size_t size, size_t alignment) { return mi_malloc_aligned(size,alignment); }
362362
#endif
363363
void* reallocarray(void* p, size_t count, size_t size) { return mi_reallocarray(p, count, size); }
364364
// some systems define reallocarr so mark it as a weak symbol (#751)

src/init.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,9 @@ void mi_cdecl mi_process_done(void) mi_attr_noexcept {
11321132
#endif
11331133
#endif
11341134

1135+
// done with tracking tools
1136+
mi_track_done()
1137+
11351138
// Forcefully release all retained memory; this can be dangerous in general if overriding regular malloc/free
11361139
// since after process_done there might still be other code running that calls `free` (like at_exit routines,
11371140
// or C-runtime termination code.

0 commit comments

Comments
 (0)