Hide FreeSlot in MemoryPoolList

This commit is contained in:
Benoit Blanchon
2024-08-25 14:39:18 +02:00
parent cec18177b0
commit f7f1b9745d
3 changed files with 6 additions and 7 deletions

View File

@ -69,12 +69,12 @@ inline SlotWithId MemoryPoolList::allocFromFreeList() {
ARDUINOJSON_ASSERT(freeList_ != NULL_SLOT);
auto id = freeList_;
auto slot = getSlot(freeList_);
freeList_ = slot->free.next;
freeList_ = reinterpret_cast<FreeSlot*>(slot)->next;
return {slot, id};
}
inline void MemoryPoolList::freeSlot(SlotWithId slot) {
slot->free.next = freeList_;
reinterpret_cast<FreeSlot*>(slot.slot())->next = freeList_;
freeList_ = slot.id();
}

View File

@ -15,6 +15,10 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
using PoolCount = SlotId;
class MemoryPoolList {
struct FreeSlot {
SlotId next;
};
public:
MemoryPoolList() = default;

View File

@ -13,15 +13,10 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
struct StringNode;
struct FreeSlot {
SlotId next;
};
union VariantSlot {
VariantSlot() {}
VariantData variant;
FreeSlot free;
};
ARDUINOJSON_END_PRIVATE_NAMESPACE