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