Add CopiedString and LinkedString

This commit is contained in:
Benoit Blanchon
2021-11-22 09:40:20 +01:00
parent b06bbd9d2a
commit 62f9b94ab1
13 changed files with 83 additions and 50 deletions

View File

@@ -173,7 +173,7 @@ struct Converter<SerializedValue<T>,
VariantData* data = getData(dst);
MemoryPool* pool = getPool(dst);
if (data)
data->setOwnedRaw(src, pool);
data->storeOwnedRaw(src, pool);
}
};
@@ -203,7 +203,7 @@ class MemoryPoolPrint : public Print {
pool->getFreeZone(&_string, &_capacity);
}
const char* c_str() {
CopiedString str() {
_string[_size++] = 0;
ARDUINOJSON_ASSERT(_size <= _capacity);
return _pool->saveStringFromFreeZone(_size);
@@ -250,7 +250,7 @@ inline void convertToJson(const ::Printable& src, VariantRef dst) {
data->setNull();
return;
}
data->setStringPointer(print.c_str(), storage_policies::store_by_copy());
data->setString(print.str());
}
#endif