| 3412 | } |
| 3413 | |
| 3414 | void Value::dupPayload(const Value& other) { |
| 3415 | setType(other.type()); |
| 3416 | setIsAllocated(false); |
| 3417 | switch (type()) { |
| 3418 | case nullValue: |
| 3419 | case intValue: |
| 3420 | case uintValue: |
| 3421 | case realValue: |
| 3422 | case booleanValue: |
| 3423 | value_ = other.value_; |
| 3424 | break; |
| 3425 | case stringValue: |
| 3426 | if (other.value_.string_ && other.isAllocated()) { |
| 3427 | unsigned len; |
| 3428 | char const* str; |
| 3429 | decodePrefixedString(other.isAllocated(), other.value_.string_, &len, |
| 3430 | &str); |
| 3431 | value_.string_ = duplicateAndPrefixStringValue(str, len); |
| 3432 | setIsAllocated(true); |
| 3433 | } else { |
| 3434 | value_.string_ = other.value_.string_; |
| 3435 | } |
| 3436 | break; |
| 3437 | case arrayValue: |
| 3438 | case objectValue: |
| 3439 | value_.map_ = new ObjectValues(*other.value_.map_); |
| 3440 | break; |
| 3441 | default: |
| 3442 | JSON_ASSERT_UNREACHABLE; |
| 3443 | } |
| 3444 | } |
| 3445 | |
| 3446 | void Value::releasePayload() { |
| 3447 | switch (type()) { |
nothing calls this directly
no test coverage detected