Add MemoryPool::deallocPool()

This commit is contained in:
Benoit Blanchon
2023-04-08 09:20:27 +02:00
parent 6eb4f45fb9
commit 7c0fa7c276

View File

@ -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;