From 639b73ecf9608d9c3078cb9dee5b7c2f46639828 Mon Sep 17 00:00:00 2001 From: Daan Date: Wed, 18 Jun 2025 01:37:16 -0700 Subject: [PATCH] refactor --- src/page-map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/page-map.c b/src/page-map.c index 65320326..40493389 100644 --- a/src/page-map.c +++ b/src/page-map.c @@ -318,13 +318,13 @@ mi_decl_nodiscard static bool mi_page_map_ensure_submap_at(size_t idx, mi_submap if mi_unlikely(sub == NULL) { // sub map not yet allocated, alloc now mi_memid_t memid; - mi_page_t** expect = sub; const size_t submap_size = MI_PAGE_MAP_SUB_SIZE; sub = (mi_submap_t)_mi_os_zalloc(submap_size, &memid); if (sub==NULL) { _mi_warning_message("internal error: unable to extend the page map\n"); return false; } + mi_submap_t expect = NULL; if (!mi_atomic_cas_ptr_strong_acq_rel(mi_page_t*, &_mi_page_map[idx], &expect, sub)) { // another thread already allocated it.. free and continue _mi_os_free(sub, submap_size, memid);