mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 18:57:32 +02:00
StringPool: change dereference
to take a StringNode*
This commit is contained in:
@ -134,8 +134,8 @@ class ResourceManager {
|
|||||||
StringNode::destroy(node, allocator_);
|
StringNode::destroy(node, allocator_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dereferenceString(const char* s) {
|
void dereferenceString(StringNode* node) {
|
||||||
stringPool_.dereference(s, allocator_);
|
stringPool_.dereference(node, allocator_);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotId saveStaticString(const char* s) {
|
SlotId saveStaticString(const char* s) {
|
||||||
|
@ -78,20 +78,20 @@ class StringPool {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dereference(const char* s, Allocator* allocator) {
|
void dereference(StringNode* nodeToRemove, Allocator* allocator) {
|
||||||
StringNode* prev = nullptr;
|
StringNode* prev = nullptr;
|
||||||
for (auto node = strings_; node; node = node->next) {
|
for (auto current = strings_; current; current = current->next) {
|
||||||
if (node->data == s) {
|
if (current == nodeToRemove) {
|
||||||
if (--node->references == 0) {
|
if (--current->references == 0) {
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->next = node->next;
|
prev->next = current->next;
|
||||||
else
|
else
|
||||||
strings_ = node->next;
|
strings_ = current->next;
|
||||||
StringNode::destroy(node, allocator);
|
StringNode::destroy(current, allocator);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
prev = node;
|
prev = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ class VariantImpl {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (data_->type & VariantTypeBits::OwnedStringBit)
|
if (data_->type & VariantTypeBits::OwnedStringBit)
|
||||||
resources_->dereferenceString(data_->content.asOwnedString->data);
|
resources_->dereferenceString(asOwnedString());
|
||||||
|
|
||||||
#if ARDUINOJSON_USE_8_BYTE_POOL
|
#if ARDUINOJSON_USE_8_BYTE_POOL
|
||||||
if (data_->type & VariantTypeBits::EightByteBit)
|
if (data_->type & VariantTypeBits::EightByteBit)
|
||||||
|
Reference in New Issue
Block a user