mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-06-07 09:04:57 +02:00
keep StaticString (!allocated_) for copy ctor
This commit is contained in:
parent
eaa06355e1
commit
493f6dcebe
@ -353,10 +353,11 @@ Value::Value(bool value) {
|
|||||||
value_.bool_ = value;
|
value_.bool_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::Value(const Value& other)
|
Value::Value(Value const& other)
|
||||||
: type_(other.type_), allocated_(false)
|
: type_(other.type_), allocated_(false)
|
||||||
,
|
,
|
||||||
comments_(0), start_(other.start_), limit_(other.limit_) {
|
comments_(0), start_(other.start_), limit_(other.limit_)
|
||||||
|
{
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case nullValue:
|
case nullValue:
|
||||||
case intValue:
|
case intValue:
|
||||||
@ -366,7 +367,7 @@ Value::Value(const Value& other)
|
|||||||
value_ = other.value_;
|
value_ = other.value_;
|
||||||
break;
|
break;
|
||||||
case stringValue:
|
case stringValue:
|
||||||
if (other.value_.string_) {
|
if (other.value_.string_ && other.allocated_) {
|
||||||
unsigned len;
|
unsigned len;
|
||||||
char const* str;
|
char const* str;
|
||||||
decodePrefixedString(other.allocated_, other.value_.string_,
|
decodePrefixedString(other.allocated_, other.value_.string_,
|
||||||
@ -374,7 +375,7 @@ Value::Value(const Value& other)
|
|||||||
value_.string_ = duplicateAndPrefixStringValue(str, len);
|
value_.string_ = duplicateAndPrefixStringValue(str, len);
|
||||||
allocated_ = true;
|
allocated_ = true;
|
||||||
} else {
|
} else {
|
||||||
value_.string_ = 0;
|
value_.string_ = other.value_.string_;
|
||||||
allocated_ = false;
|
allocated_ = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user