Fix JsonVariant::memoryUsage() for raw strings

This commit is contained in:
Benoit Blanchon
2021-11-12 16:55:41 +01:00
parent 0429016ff1
commit 599e927590
3 changed files with 7 additions and 2 deletions

View File

@ -257,7 +257,9 @@ class VariantData {
case VALUE_IS_OWNED_STRING:
return strlen(_content.asString) + 1;
case VALUE_IS_OWNED_RAW:
return _content.asRaw.size;
// We always add a zero at the end: the deduplication function uses it
// to detect the beginning of the next string.
return _content.asRaw.size + 1;
case VALUE_IS_OBJECT:
case VALUE_IS_ARRAY:
return _content.asCollection.memoryUsage();