From 7c0fa7c27628c9940005728c7cd778afa4172a81 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sat, 8 Apr 2023 09:20:27 +0200 Subject: [PATCH] Add `MemoryPool::deallocPool()` --- src/ArduinoJson/Memory/MemoryPool.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ArduinoJson/Memory/MemoryPool.hpp b/src/ArduinoJson/Memory/MemoryPool.hpp index 4964f8e9..110f6e02 100644 --- a/src/ArduinoJson/Memory/MemoryPool.hpp +++ b/src/ArduinoJson/Memory/MemoryPool.hpp @@ -46,16 +46,14 @@ class MemoryPool { } ~MemoryPool() { - if (_begin) - _allocator->deallocate(_begin); + deallocPool(); } MemoryPool(const MemoryPool&) = delete; MemoryPool& operator=(const MemoryPool& src) = delete; MemoryPool& operator=(MemoryPool&& src) { - if (_begin) - _allocator->deallocate(_begin); + deallocPool(); _allocator = src._allocator; _begin = src._begin; _end = src._end; @@ -265,6 +263,11 @@ class MemoryPool { ARDUINOJSON_ASSERT(isAligned(_end)); } + void deallocPool() { + if (_begin) + _allocator->deallocate(_begin); + } + Allocator* _allocator; char *_begin, *_left, *_right, *_end; bool _overflowed;