mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 07:29:30 +03:00
Merge branch 'dev' into dev-slice
This commit is contained in:
commit
11ddba7a06
6 changed files with 32 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(libmimalloc C CXX)
|
project(libmimalloc C CXX)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect32.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect32.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect32.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect32.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect32.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect32.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect32.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect32.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect32.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect32.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect32.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect32.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
<Message>Copy mimalloc-redirect32.dll to the output directory</Message>
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
</Link>
|
</Link>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Command>COPY /Y $(ProjectDir)..\..\bin\mimalloc-redirect.dll $(OutputPath)</Command>
|
<Command>COPY /Y "$(ProjectDir)..\..\bin\mimalloc-redirect.dll" "$(OutputPath)"</Command>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
<Message>copy mimalloc-redirect.dll to the output directory</Message>
|
||||||
|
|
22
src/alloc.c
22
src/alloc.c
|
@ -786,7 +786,9 @@ mi_decl_nodiscard mi_decl_restrict char* mi_heap_strdup(mi_heap_t* heap, const c
|
||||||
if (s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
size_t n = strlen(s);
|
size_t n = strlen(s);
|
||||||
char* t = (char*)mi_heap_malloc(heap,n+1);
|
char* t = (char*)mi_heap_malloc(heap,n+1);
|
||||||
if (t != NULL) _mi_memcpy(t, s, n + 1);
|
if (t == NULL) return NULL;
|
||||||
|
_mi_memcpy(t, s, n);
|
||||||
|
t[n] = 0;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,6 +839,7 @@ mi_decl_nodiscard mi_decl_restrict char* mi_heap_realpath(mi_heap_t* heap, const
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#include <unistd.h> // pathconf
|
#include <unistd.h> // pathconf
|
||||||
|
/*
|
||||||
static size_t mi_path_max(void) {
|
static size_t mi_path_max(void) {
|
||||||
static size_t path_max = 0;
|
static size_t path_max = 0;
|
||||||
if (path_max <= 0) {
|
if (path_max <= 0) {
|
||||||
|
@ -847,20 +850,31 @@ static size_t mi_path_max(void) {
|
||||||
}
|
}
|
||||||
return path_max;
|
return path_max;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept {
|
char* mi_heap_realpath(mi_heap_t* heap, const char* fname, char* resolved_name) mi_attr_noexcept {
|
||||||
if (resolved_name != NULL) {
|
if (resolved_name != NULL) {
|
||||||
return realpath(fname,resolved_name);
|
return realpath(fname,resolved_name);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size_t n = mi_path_max();
|
char* rname = realpath(fname, NULL);
|
||||||
|
if (rname == NULL) return NULL;
|
||||||
|
char* result = mi_heap_strdup(heap, rname);
|
||||||
|
free(rname); // use regular free! (which may be redirected to our free but that's ok)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
const size_t n = mi_path_max();
|
||||||
char* buf = (char*)mi_malloc(n+1);
|
char* buf = (char*)mi_malloc(n+1);
|
||||||
if (buf==NULL) return NULL;
|
if (buf == NULL) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
char* rname = realpath(fname,buf);
|
char* rname = realpath(fname,buf);
|
||||||
char* result = mi_heap_strndup(heap,rname,n); // ok if `rname==NULL`
|
char* result = mi_heap_strndup(heap,rname,n); // ok if `rname==NULL`
|
||||||
mi_free(buf);
|
mi_free(buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ static void heap_thread_free_huge();
|
||||||
|
|
||||||
static void test_stl_allocators();
|
static void test_stl_allocators();
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
mi_stats_reset(); // ignore earlier allocations
|
mi_stats_reset(); // ignore earlier allocations
|
||||||
heap_thread_free_huge();
|
heap_thread_free_huge();
|
||||||
|
|
Loading…
Add table
Reference in a new issue