| 3664 | } |
| 3665 | |
| 3666 | void Value::dupPayload(const Value &other) |
| 3667 | { |
| 3668 | setType(other.type()); |
| 3669 | setIsAllocated(false); |
| 3670 | switch (type()) |
| 3671 | { |
| 3672 | case nullValue: |
| 3673 | case intValue: |
| 3674 | case uintValue: |
| 3675 | case realValue: |
| 3676 | case booleanValue: |
| 3677 | value_ = other.value_; |
| 3678 | break; |
| 3679 | case stringValue: |
| 3680 | if (other.value_.string_ && other.isAllocated()) |
| 3681 | { |
| 3682 | unsigned len; |
| 3683 | char const *str; |
| 3684 | decodePrefixedString(other.isAllocated(), other.value_.string_, &len, &str); |
| 3685 | value_.string_ = duplicateAndPrefixStringValue(str, len); |
| 3686 | setIsAllocated(true); |
| 3687 | } |
| 3688 | else |
| 3689 | { |
| 3690 | value_.string_ = other.value_.string_; |
| 3691 | } |
| 3692 | break; |
| 3693 | case arrayValue: |
| 3694 | case objectValue: |
| 3695 | value_.map_ = new ObjectValues(*other.value_.map_); |
| 3696 | break; |
| 3697 | default: |
| 3698 | JSON_ASSERT_UNREACHABLE; |
| 3699 | } |
| 3700 | } |
| 3701 | |
| 3702 | void Value::releasePayload() |
| 3703 | { |
nothing calls this directly
no test coverage detected