File tree Expand file tree Collapse file tree 7 files changed +34
-61
lines changed
Expand file tree Collapse file tree 7 files changed +34
-61
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>
87#include < catch.hpp>
98
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 < catch.hpp>
87
98#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>
76#include < catch.hpp>
87
98#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>
87#include < catch.hpp>
98
109#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 @@ -55,14 +55,42 @@ class ResourceManager {
5555 return overflowed_;
5656 }
5757
58- Slot<VariantData> allocVariant ();
59- void freeVariant (Slot<VariantData> slot);
60- VariantData* getVariant (SlotId id) const ;
58+ Slot<VariantData> allocVariant () {
59+ auto slot = variantPools_.allocSlot (allocator_);
60+ if (!slot) {
61+ overflowed_ = true ;
62+ return {};
63+ }
64+ new (slot.ptr ()) VariantData ();
65+ return slot;
66+ }
67+
68+ void freeVariant (Slot<VariantData> slot) {
69+ variantPools_.freeSlot (slot);
70+ }
71+
72+ VariantData* getVariant (SlotId id) const {
73+ return variantPools_.getSlot (id);
74+ }
6175
6276#if ARDUINOJSON_USE_8_BYTE_POOL
63- Slot<EightByteValue> allocEightByte ();
64- void freeEightByte (SlotId slot);
65- 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+ }
6694#endif
6795
6896 template <typename TAdaptedString>
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments