From dc57d0e18eea31cd83572ce75b440709173dcb12 Mon Sep 17 00:00:00 2001 From: Zhanghao Chen Date: Mon, 29 Dec 2025 13:46:41 +0800 Subject: [PATCH] chore: simplify constructing MemoryPoolAllocator with user supplied buffer by creating new BaseAllocator internally on default --- include/sonic/allocator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sonic/allocator.h b/include/sonic/allocator.h index 2c28ce2..52958ac 100644 --- a/include/sonic/allocator.h +++ b/include/sonic/allocator.h @@ -255,7 +255,7 @@ class MemoryPoolAllocator { size_t chunkSize = SONIC_ALLOCATOR_MIN_CHUNK_CAPACITY, BaseAllocator* baseAllocator = 0) : cp_(chunkSize), - baseAllocator_(baseAllocator), + baseAllocator_(baseAllocator ? baseAllocator : new BaseAllocator()), shared_(static_cast(AlignBuffer(buffer, size))) { sonic_assert(size >= SIZEOF_SHARED_DATA + SIZEOF_CHUNK_HEADER); shared_->chunkHead = GetChunkHead(shared_);