From 58e743b83f0949ecfa4732eaec0288672c55123f Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Wed, 21 Aug 2024 11:30:00 -0700 Subject: [PATCH] fix use_guarded signature --- src/alloc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index c91de62d..ca60c11a 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -123,7 +123,7 @@ extern void* _mi_page_malloc_zeroed(mi_heap_t* heap, mi_page_t* page, size_t siz #if MI_DEBUG_GUARDED static mi_decl_restrict void* mi_heap_malloc_guarded(mi_heap_t* heap, size_t size, bool zero) mi_attr_noexcept; -static inline bool mi_heap_malloc_use_guarded(size_t size, bool huge_alignment); +static inline bool mi_heap_malloc_use_guarded(size_t size, bool has_huge_alignment); static inline bool mi_heap_malloc_small_use_guarded(size_t size); #endif @@ -177,7 +177,7 @@ extern inline void* _mi_heap_malloc_zero_ex(mi_heap_t* heap, size_t size, bool z return mi_heap_malloc_small_zero(heap, size, zero); } #if MI_DEBUG_GUARDED - else if (mi_use_guarded(size,huge_alignment)) { return mi_heap_malloc_guarded(heap, size, zero); } + else if (mi_heap_malloc_use_guarded(size,huge_alignment>0)) { return mi_heap_malloc_guarded(heap, size, zero); } #endif else { // regular allocation @@ -607,8 +607,8 @@ static inline bool mi_heap_malloc_small_use_guarded(size_t size) { && size >= (size_t)_mi_option_get_fast(mi_option_debug_guarded_min)); } -static inline bool mi_heap_malloc_use_guarded(size_t size, bool huge_alignment) { - return (huge_alignment == 0 // guarded pages do not work with huge aligments at the moment +static inline bool mi_heap_malloc_use_guarded(size_t size, bool has_huge_alignment) { + return (!has_huge_alignment // guarded pages do not work with huge aligments at the moment && _mi_option_get_fast(mi_option_debug_guarded_max) > 0 // guarded must be enabled && (mi_heap_malloc_small_use_guarded(size) || ((mi_good_size(size) & (_mi_os_page_size() - 1)) == 0)) // page-size multiple are always guarded so we can have a correct `mi_usable_size`.