mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-29 18:27:37 +02:00
CollectionData::releaseSlot()
takes an iterator
This commit is contained in:
@ -110,10 +110,10 @@ class CollectionData {
|
||||
|
||||
protected:
|
||||
iterator addSlot(ResourceManager*);
|
||||
void releaseSlot(iterator, ResourceManager*);
|
||||
|
||||
private:
|
||||
SlotWithId getPreviousSlot(VariantSlot*, const ResourceManager*) const;
|
||||
static void releaseSlot(VariantSlot*, ResourceManager*);
|
||||
};
|
||||
|
||||
inline const VariantData* collectionToVariant(
|
||||
|
@ -65,7 +65,7 @@ inline CollectionData::iterator CollectionData::addSlot(
|
||||
|
||||
inline void CollectionData::clear(ResourceManager* resources) {
|
||||
for (auto it = createIterator(resources); !it.done(); it.next(resources))
|
||||
releaseSlot(it.slot_, resources);
|
||||
releaseSlot(it, resources);
|
||||
head_ = NULL_SLOT;
|
||||
tail_ = NULL_SLOT;
|
||||
}
|
||||
@ -96,7 +96,7 @@ inline void CollectionData::remove(iterator it, ResourceManager* resources) {
|
||||
head_ = next;
|
||||
if (next == NULL_SLOT)
|
||||
tail_ = prev.id();
|
||||
releaseSlot(curr, resources);
|
||||
releaseSlot(it, resources);
|
||||
}
|
||||
|
||||
inline size_t CollectionData::memoryUsage(
|
||||
@ -127,12 +127,12 @@ inline size_t CollectionData::size(const ResourceManager* resources) const {
|
||||
return count;
|
||||
}
|
||||
|
||||
inline void CollectionData::releaseSlot(VariantSlot* slot,
|
||||
inline void CollectionData::releaseSlot(iterator it,
|
||||
ResourceManager* resources) {
|
||||
ARDUINOJSON_ASSERT(slot != nullptr);
|
||||
if (slot->ownsKey())
|
||||
resources->dereferenceString(slot->key());
|
||||
slot->data()->setNull(resources);
|
||||
ARDUINOJSON_ASSERT(!it.done());
|
||||
if (it.ownsKey())
|
||||
resources->dereferenceString(it.key());
|
||||
it->setNull(resources);
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
Reference in New Issue
Block a user