|
|
@@ -57,14 +57,42 @@ class ResourceManager {
|
|
|
return overflowed_;
|
|
|
}
|
|
|
|
|
|
- Slot<VariantData> allocVariant();
|
|
|
- void freeVariant(Slot<VariantData> slot);
|
|
|
- VariantData* getVariant(SlotId id) const;
|
|
|
+ Slot<VariantData> allocVariant() {
|
|
|
+ auto slot = variantPools_.allocSlot(allocator_);
|
|
|
+ if (!slot) {
|
|
|
+ overflowed_ = true;
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ new (slot.ptr()) VariantData();
|
|
|
+ return slot;
|
|
|
+ }
|
|
|
+
|
|
|
+ void freeVariant(Slot<VariantData> slot) {
|
|
|
+ variantPools_.freeSlot(slot);
|
|
|
+ }
|
|
|
+
|
|
|
+ VariantData* getVariant(SlotId id) const {
|
|
|
+ return variantPools_.getSlot(id);
|
|
|
+ }
|
|
|
|
|
|
#if ARDUINOJSON_USE_8_BYTE_POOL
|
|
|
- Slot<EightByteValue> allocEightByte();
|
|
|
- void freeEightByte(SlotId slot);
|
|
|
- EightByteValue* getEightByte(SlotId id) const;
|
|
|
+ Slot<EightByteValue> allocEightByte() {
|
|
|
+ auto slot = eightBytePools_.allocSlot(allocator_);
|
|
|
+ if (!slot) {
|
|
|
+ overflowed_ = true;
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ return slot;
|
|
|
+ }
|
|
|
+
|
|
|
+ void freeEightByte(SlotId id) {
|
|
|
+ auto p = getEightByte(id);
|
|
|
+ eightBytePools_.freeSlot({p, id});
|
|
|
+ }
|
|
|
+
|
|
|
+ EightByteValue* getEightByte(SlotId id) const {
|
|
|
+ return eightBytePools_.getSlot(id);
|
|
|
+ }
|
|
|
#endif
|
|
|
|
|
|
template <typename TAdaptedString>
|