File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -269,10 +269,10 @@ inline size_t sizeofPoolList(size_t n = ARDUINOJSON_INITIAL_POOL_COUNT) {
269269 return sizeof (MemoryPool<VariantData>) * n;
270270}
271271
272+ template <typename T = ArduinoJson::detail::VariantData>
272273inline size_t sizeofPool (
273274 ArduinoJson::detail::SlotCount n = ARDUINOJSON_POOL_CAPACITY) {
274- using namespace ArduinoJson ::detail;
275- return MemoryPool<VariantData>::slotsToBytes (n);
275+ return ArduinoJson::detail::MemoryPool<T>::slotsToBytes (n);
276276}
277277
278278inline size_t sizeofStaticStringPool (
Original file line number Diff line number Diff line change 88#include " Allocators.hpp"
99#include " Literals.hpp"
1010
11- using ArduinoJson::detail::sizeofArray ;
11+ using namespace ArduinoJson ::detail;
1212
1313TEST_CASE (" JsonArray::add(T)" ) {
1414 SpyingAllocator spy;
@@ -33,7 +33,8 @@ TEST_CASE("JsonArray::add(T)") {
3333 REQUIRE (array[0 ].is <double >());
3434 REQUIRE_FALSE (array[0 ].is <bool >());
3535 REQUIRE (spy.log () == AllocatorLog{
36- Allocate (sizeofPool ()),
36+ Allocate (sizeofPool<VariantData>()),
37+ Allocate (sizeofPool<EightByteValue>()),
3738 });
3839 }
3940
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ class ResourceManager {
3030 stringPool_.clear (allocator_);
3131 variantPools_.clear (allocator_);
3232 staticStringsPools_.clear (allocator_);
33+ #if ARDUINOJSON_USE_8_BYTE_POOL
34+ eightBytePools_.clear (allocator_);
35+ #endif
3336 }
3437
3538 ResourceManager (const ResourceManager&) = delete ;
@@ -39,8 +42,9 @@ class ResourceManager {
3942 swap (a.stringPool_ , b.stringPool_ );
4043 swap (a.variantPools_ , b.variantPools_ );
4144 swap (a.staticStringsPools_ , b.staticStringsPools_ );
45+ #if ARDUINOJSON_USE_8_BYTE_POOL
4246 swap (a.eightBytePools_ , b.eightBytePools_ );
43- swap_ (a. allocator_ , b. allocator_ );
47+ # endif
4448 swap_ (a.overflowed_ , b.overflowed_ );
4549 }
4650
You can’t perform that action at this time.
0 commit comments