Rename SlotWithId::slot() and VariantWithId::data() to ptr()

This commit is contained in:
Benoit Blanchon
2024-08-25 14:54:45 +02:00
parent 4327f72140
commit 2be24eded8
9 changed files with 28 additions and 28 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ inline VariantData* ArrayData::addElement(ResourceManager* resources) {
if (!slot)
return nullptr;
CollectionData::appendOne(slot, resources);
return slot.data();
return slot.ptr();
}
inline VariantData* ArrayData::getOrAddElement(size_t index,
@@ -62,7 +62,7 @@ inline bool ArrayData::addValue(T&& value, ResourceManager* resources) {
auto slot = resources->allocVariant();
if (!slot)
return false;
JsonVariant variant(slot.data(), resources);
JsonVariant variant(slot.ptr(), resources);
if (!variant.set(detail::forward<T>(value))) {
resources->freeVariant(slot);
return false;
+1 -1
View File
@@ -30,7 +30,7 @@ class SlotWithId {
return id_;
}
VariantData* slot() const {
VariantData* ptr() const {
return slot_;
}
+1 -1
View File
@@ -74,7 +74,7 @@ inline SlotWithId MemoryPoolList::allocFromFreeList() {
}
inline void MemoryPoolList::freeSlot(SlotWithId slot) {
reinterpret_cast<FreeSlot*>(slot.slot())->next = freeList_;
reinterpret_cast<FreeSlot*>(slot.ptr())->next = freeList_;
freeList_ = slot.id();
}
+1 -1
View File
@@ -145,7 +145,7 @@ class MemoryPoolList {
auto slot = pools_[poolIndex].allocSlot();
if (!slot)
return {};
return {slot.slot(),
return {slot.ptr(),
SlotId(poolIndex * ARDUINOJSON_POOL_CAPACITY + slot.id())};
}
@@ -16,7 +16,7 @@ inline VariantWithId ResourceManager::allocVariant() {
overflowed_ = true;
return {};
}
return {new (p.slot()) VariantData, p.id()};
return {new (p.ptr()) VariantData, p.id()};
}
inline void ResourceManager::freeVariant(VariantWithId variant) {
+1 -1
View File
@@ -65,7 +65,7 @@ inline VariantData* ObjectData::addMember(TAdaptedString key,
CollectionData::appendPair(keySlot, valueSlot, resources);
return valueSlot.data();
return valueSlot.ptr();
}
// Returns the size (in bytes) of an object with n members.
+4 -4
View File
@@ -540,13 +540,13 @@ class VariantWithId : public SlotWithId {
VariantWithId(VariantData* data, SlotId id)
: SlotWithId(reinterpret_cast<VariantData*>(data), id) {}
VariantData* data() {
return reinterpret_cast<VariantData*>(slot());
VariantData* ptr() {
return reinterpret_cast<VariantData*>(SlotWithId::ptr());
}
VariantData* operator->() {
ARDUINOJSON_ASSERT(data() != nullptr);
return data();
ARDUINOJSON_ASSERT(ptr() != nullptr);
return ptr();
}
};