Skip to content

Commit 7c0fa7c

Browse files
committed
Add MemoryPool::deallocPool()
1 parent 6eb4f45 commit 7c0fa7c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ArduinoJson/Memory/MemoryPool.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,14 @@ class MemoryPool {
4646
}
4747

4848
~MemoryPool() {
49-
if (_begin)
50-
_allocator->deallocate(_begin);
49+
deallocPool();
5150
}
5251

5352
MemoryPool(const MemoryPool&) = delete;
5453
MemoryPool& operator=(const MemoryPool& src) = delete;
5554

5655
MemoryPool& operator=(MemoryPool&& src) {
57-
if (_begin)
58-
_allocator->deallocate(_begin);
56+
deallocPool();
5957
_allocator = src._allocator;
6058
_begin = src._begin;
6159
_end = src._end;
@@ -265,6 +263,11 @@ class MemoryPool {
265263
ARDUINOJSON_ASSERT(isAligned(_end));
266264
}
267265

266+
void deallocPool() {
267+
if (_begin)
268+
_allocator->deallocate(_begin);
269+
}
270+
268271
Allocator* _allocator;
269272
char *_begin, *_left, *_right, *_end;
270273
bool _overflowed;

0 commit comments

Comments
 (0)