mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-10 01:09:31 +03:00
merge from dev
This commit is contained in:
commit
7c058f207c
2 changed files with 10 additions and 5 deletions
|
@ -18,12 +18,15 @@ jobs:
|
||||||
Debug:
|
Debug:
|
||||||
BuildType: debug
|
BuildType: debug
|
||||||
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON
|
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Debug -DMI_DEBUG_FULL=ON
|
||||||
|
MSBuildConfiguration: Debug
|
||||||
Release:
|
Release:
|
||||||
BuildType: release
|
BuildType: release
|
||||||
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release
|
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release
|
||||||
|
MSBuildConfiguration: Release
|
||||||
Secure:
|
Secure:
|
||||||
BuildType: secure
|
BuildType: secure
|
||||||
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release -DMI_SECURE=ON
|
cmakeExtraArgs: -DCMAKE_BUILD_TYPE=Release -DMI_SECURE=ON
|
||||||
|
MSBuildConfiguration: Release
|
||||||
steps:
|
steps:
|
||||||
- task: CMake@1
|
- task: CMake@1
|
||||||
inputs:
|
inputs:
|
||||||
|
@ -32,6 +35,7 @@ jobs:
|
||||||
- task: MSBuild@1
|
- task: MSBuild@1
|
||||||
inputs:
|
inputs:
|
||||||
solution: $(BuildType)/libmimalloc.sln
|
solution: $(BuildType)/libmimalloc.sln
|
||||||
|
configuration: '$(MSBuildConfiguration)'
|
||||||
- script: |
|
- script: |
|
||||||
cd $(BuildType)
|
cd $(BuildType)
|
||||||
ctest
|
ctest
|
||||||
|
|
11
src/alloc.c
11
src/alloc.c
|
@ -693,12 +693,13 @@ MI_ALLOC_API1(mi_decl_restrict char*, strdup, mi_heap_t*, heap, const char*, s)
|
||||||
MI_ALLOC_API2(mi_decl_restrict char*, strndup, mi_heap_t*, heap, const char*, s, size_t, n)
|
MI_ALLOC_API2(mi_decl_restrict char*, strndup, mi_heap_t*, heap, const char*, s, size_t, n)
|
||||||
{
|
{
|
||||||
if (s == NULL) return NULL;
|
if (s == NULL) return NULL;
|
||||||
size_t m = strlen(s);
|
const char* end = (const char*)memchr(s, 0, n); // find end of string in the first `n` characters (returns NULL if not found)
|
||||||
if (n > m) n = m;
|
const size_t m = (end != NULL ? (end - s) : n); // `m` is the minimum of `n` or the end-of-string
|
||||||
char* t = (char*)MI_SOURCE_ARG(mi_heap_malloc, heap, n+1);
|
mi_assert_internal(m <= n);
|
||||||
|
char* t = (char*)MI_SOURCE_ARG(mi_heap_malloc, heap, m+1);
|
||||||
if (t == NULL) return NULL;
|
if (t == NULL) return NULL;
|
||||||
memcpy(t, s, n);
|
memcpy(t, s, m);
|
||||||
t[n] = 0;
|
t[m] = 0;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue