From 3c563816c0d13b770bacb4336003e9d9d64ab8b2 Mon Sep 17 00:00:00 2001 From: daan Date: Tue, 3 Sep 2019 18:25:01 -0700 Subject: [PATCH] read regions count on every loop iteration --- src/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/memory.c b/src/memory.c index 9ad49cca..338b1ba3 100644 --- a/src/memory.c +++ b/src/memory.c @@ -398,7 +398,7 @@ void* _mi_mem_alloc_aligned(size_t size, size_t alignment, bool* commit, bool* l if (p == NULL) { // no free range in existing regions -- try to extend beyond the count.. but at most 8 regions - for (idx = count; idx < count + 8 && idx < MI_REGION_MAX; idx++) { + for (idx = count; idx < mi_atomic_read_relaxed(®ions_count) + 8 && idx < MI_REGION_MAX; idx++) { if (!mi_region_try_alloc_blocks(idx, blocks, size, commit, large, is_zero, &p, id, tld)) return NULL; // error if (p != NULL) break; }