Merge branch 'dev' into dev-slice

This commit is contained in:
daanx 2023-05-19 21:22:24 -07:00
commit 24668b9daf
2 changed files with 14 additions and 4 deletions

View file

@ -175,11 +175,17 @@ static void* mi_arena_meta_zalloc(size_t size, mi_memid_t* memid, mi_stats_t* st
*memid = _mi_memid_none(); *memid = _mi_memid_none();
// try static // try static
void* p = mi_arena_static_zalloc(size, MI_ALIGNMENT_MAX, memid); void* p = mi_arena_static_zalloc(size, MI_MAX_ALIGN_SIZE, memid);
if (p != NULL) return p; if (p != NULL) return p;
// or fall back to the OS // or fall back to the OS
return _mi_os_alloc(size, memid, stats); p = _mi_os_alloc(size, memid, stats);
if (p == NULL) return NULL;
if (!memid->initially_zero) {
_mi_memzero_aligned(p, size);
}
return p;
} }
static void mi_arena_meta_free(void* p, mi_memid_t memid, size_t size, mi_stats_t* stats) { static void mi_arena_meta_free(void* p, mi_memid_t memid, size_t size, mi_stats_t* stats) {

View file

@ -94,6 +94,10 @@ static mi_option_desc_t options[_mi_option_last] =
static void mi_option_init(mi_option_desc_t* desc); static void mi_option_init(mi_option_desc_t* desc);
static bool mi_option_has_size_in_kib(mi_option_t option) {
return (option == mi_option_reserve_os_memory || option == mi_option_arena_reserve);
}
void _mi_options_init(void) { void _mi_options_init(void) {
// called on process load; should not be called before the CRT is initialized! // called on process load; should not be called before the CRT is initialized!
// (e.g. do not call this from process_init as that may run before CRT initialization) // (e.g. do not call this from process_init as that may run before CRT initialization)
@ -104,7 +108,7 @@ void _mi_options_init(void) {
// if (option != mi_option_verbose) // if (option != mi_option_verbose)
{ {
mi_option_desc_t* desc = &options[option]; mi_option_desc_t* desc = &options[option];
_mi_verbose_message("option '%s': %ld\n", desc->name, desc->value); _mi_verbose_message("option '%s': %ld %s\n", desc->name, desc->value, (mi_option_has_size_in_kib(option) ? "KiB" : ""));
} }
} }
mi_max_error_count = mi_option_get(mi_option_max_errors); mi_max_error_count = mi_option_get(mi_option_max_errors);
@ -128,7 +132,7 @@ mi_decl_nodiscard long mi_option_get_clamp(mi_option_t option, long min, long ma
} }
mi_decl_nodiscard size_t mi_option_get_size(mi_option_t option) { mi_decl_nodiscard size_t mi_option_get_size(mi_option_t option) {
mi_assert_internal(option == mi_option_reserve_os_memory || option == mi_option_arena_reserve); mi_assert_internal(mi_option_has_size_in_kib(option));
long x = mi_option_get(option); long x = mi_option_get(option);
return (x < 0 ? 0 : (size_t)x * MI_KiB); return (x < 0 ? 0 : (size_t)x * MI_KiB);
} }