File tree Expand file tree Collapse file tree 7 files changed +39
-62
lines changed Expand file tree Collapse file tree 7 files changed +39
-62
lines changed Original file line number Diff line number Diff line change 33// MIT License
44
55#include < ArduinoJson/Memory/ResourceManager.hpp>
6- #include < ArduinoJson/Memory/ResourceManagerImpl.hpp>
76#include < ArduinoJson/Strings/StringAdapters.hpp>
7+
88#include < catch.hpp>
99
1010using namespace ArduinoJson ::detail;
Original file line number Diff line number Diff line change 33// MIT License
44
55#include < ArduinoJson/Memory/ResourceManager.hpp>
6- # include < ArduinoJson/Memory/ResourceManagerImpl.hpp >
6+
77#include < catch.hpp>
88
99#include " Allocators.hpp"
Original file line number Diff line number Diff line change 33// MIT License
44
55#include < ArduinoJson/Memory/ResourceManager.hpp>
6- # include < ArduinoJson/Memory/ResourceManagerImpl.hpp >
6+
77#include < catch.hpp>
88
99#include " Allocators.hpp"
Original file line number Diff line number Diff line change 44
55#include < ArduinoJson/Memory/Alignment.hpp>
66#include < ArduinoJson/Memory/ResourceManager.hpp>
7- # include < ArduinoJson/Memory/ResourceManagerImpl.hpp >
7+
88#include < catch.hpp>
99
1010#include " Allocators.hpp"
Original file line number Diff line number Diff line change 4545#include " ArduinoJson/Array/ElementProxy.hpp"
4646#include " ArduinoJson/Array/Utilities.hpp"
4747#include " ArduinoJson/Collection/CollectionImpl.hpp"
48- #include " ArduinoJson/Memory/ResourceManagerImpl.hpp"
4948#include " ArduinoJson/Object/MemberProxy.hpp"
5049#include " ArduinoJson/Object/ObjectImpl.hpp"
5150#include " ArduinoJson/Variant/ConverterImpl.hpp"
Original file line number Diff line number Diff line change @@ -54,14 +54,43 @@ class ResourceManager {
5454 return overflowed_;
5555 }
5656
57- Slot<VariantData> allocVariant ();
58- void freeVariant (Slot<VariantData> slot);
59- VariantData* getVariant (SlotId id) const ;
57+ Slot<VariantData> allocVariant () {
58+ auto slot = variantPools_.allocSlot (allocator_);
59+ if (!slot) {
60+ overflowed_ = true ;
61+ return {};
62+ }
63+ new (slot.ptr ()) VariantData ();
64+ return slot;
65+ }
66+
67+ void freeVariant (Slot<VariantData> slot) {
68+ ARDUINOJSON_ASSERT (slot->type == VariantType::Null);
69+ variantPools_.freeSlot (slot);
70+ }
71+
72+ VariantData* getVariant (SlotId id) const {
73+ return reinterpret_cast <VariantData*>(variantPools_.getSlot (id));
74+ }
6075
6176#if ARDUINOJSON_USE_8_BYTE_POOL
62- Slot<EightByteValue> allocEightByte ();
63- void freeEightByte (SlotId slot);
64- EightByteValue* getEightByte (SlotId id) const ;
77+ Slot<EightByteValue> allocEightByte () {
78+ auto slot = eightBytePools_.allocSlot (allocator_);
79+ if (!slot) {
80+ overflowed_ = true ;
81+ return {};
82+ }
83+ return slot;
84+ }
85+
86+ void freeEightByte (SlotId id) {
87+ auto p = getEightByte (id);
88+ eightBytePools_.freeSlot ({p, id});
89+ }
90+
91+ EightByteValue* getEightByte (SlotId id) const {
92+ return eightBytePools_.getSlot (id);
93+ }
6594#endif
6695
6796 template <typename TAdaptedString>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments