From f6504fc7d45b86d5aef99f98b9fc88d478037101 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Wed, 12 Oct 2022 19:26:32 +0200 Subject: [PATCH] Make try_init_allocator() a ctor --- dlmalloc/src/malloc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dlmalloc/src/malloc.c b/dlmalloc/src/malloc.c index 03da739e1..4ad6a22f0 100644 --- a/dlmalloc/src/malloc.c +++ b/dlmalloc/src/malloc.c @@ -4562,7 +4562,7 @@ static void* tmalloc_small(mstate m, size_t nb) { #if __wasilibc_unmodified_upstream // Forward declaration of try_init_allocator. #else -static void try_init_allocator(void); +__attribute__((constructor(0))) static void try_init_allocator(void); #endif void* dlmalloc(size_t bytes) { @@ -4593,13 +4593,6 @@ void* dlmalloc(size_t bytes) { ensure_initialization(); /* initialize in sys_alloc if not using locks */ #endif -#if __wasilibc_unmodified_upstream // Try to initialize the allocator. -#else - if (!is_initialized(gm)) { - try_init_allocator(); - } -#endif - if (!PREACTION(gm)) { void* mem; size_t nb;