Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67f20a3

Browse files
committed
Backport fixes from dev branch
1 parent 67bd38c commit 67f20a3

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Include/mimalloc/mimalloc-types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,15 @@ struct mi_heap_s {
441441
// Debug
442442
// ------------------------------------------------------
443443

444+
#if !defined(MI_DEBUG_UNINIT)
444445
#define MI_DEBUG_UNINIT (0xD0)
446+
#endif
447+
#if !defined(MI_DEBUG_FREED)
445448
#define MI_DEBUG_FREED (0xDF)
449+
#endif
450+
#if !defined(MI_DEBUG_PADDING)
446451
#define MI_DEBUG_PADDING (0xDE)
452+
#endif
447453

448454
#if (MI_DEBUG)
449455
// use our own assertion to print without memory allocation

Objects/mimalloc/os.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ void _mi_os_init() {
229229
static void os_detect_overcommit(void) {
230230
#if defined(__linux__)
231231
int fd = open("/proc/sys/vm/overcommit_memory", O_RDONLY);
232-
if (fd < 0) return;
232+
if (fd < 0) return;
233233
char buf[128];
234234
ssize_t nread = read(fd, &buf, sizeof(buf));
235-
close(fd);
235+
close(fd);
236236
// <https://www.kernel.org/doc/Documentation/vm/overcommit-accounting>
237237
// 0: heuristic overcommit, 1: always overcommit, 2: never overcommit (ignore NORESERVE)
238238
if (nread >= 1) {
@@ -635,11 +635,11 @@ static void* mi_os_mem_alloc(size_t size, size_t try_alignment, bool commit, boo
635635
if (commit) flags |= MEM_COMMIT;
636636
p = mi_win_virtual_alloc(NULL, size, try_alignment, flags, false, allow_large, is_large);
637637
#elif defined(MI_USE_SBRK)
638-
KK_UNUSED(allow_large);
638+
MI_UNUSED(allow_large);
639639
*is_large = false;
640640
p = mi_sbrk_heap_grow(size, try_alignment);
641641
#elif defined(__wasi__)
642-
KK_UNUSED(allow_large);
642+
MI_UNUSED(allow_large);
643643
*is_large = false;
644644
p = mi_wasm_heap_grow(size, try_alignment);
645645
#else
@@ -987,7 +987,7 @@ static bool mi_os_protectx(void* addr, size_t size, bool protect) {
987987
if (csize == 0) return false;
988988
/*
989989
if (_mi_os_is_huge_reserved(addr)) {
990-
_mi_warning_message("cannot mprotect memory allocated in huge OS pages\n");
990+
_mi_warning_message("cannot mprotect memory allocated in huge OS pages\n");
991991
}
992992
*/
993993
int err = 0;

0 commit comments

Comments
 (0)