Skip to content

Commit

Permalink
no struct init
Browse files Browse the repository at this point in the history
The C struct initializer is not standard C++.
GCC and Clang handle this (at least in some versions) but some
compilers might not.
  • Loading branch information
cdunn2001 committed Mar 3, 2015
1 parent 0c91927 commit 24f5449
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib_json/json_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,23 @@ void Value::CommentInfo::setComment(const char* text, size_t len) {
Value::CZString::CZString(ArrayIndex index) : cstr_(0), index_(index) {}

Value::CZString::CZString(char const* str, unsigned length, DuplicationPolicy allocate)
: cstr_(allocate == duplicate ? duplicateStringValue(str) : str),
storage_({allocate, length})
{}
: cstr_(allocate == duplicate ? duplicateStringValue(str) : str)
{
storage_.policy_ = allocate;
storage_.length_ = length;
}

Value::CZString::CZString(const CZString& other)
: cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0
? duplicateStringValue(other.cstr_)
: other.cstr_),
storage_({(other.cstr_
: other.cstr_)
{
storage_.policy_ = (other.cstr_
? (other.storage_.policy_ == noDuplication
? noDuplication : duplicate)
: other.storage_.policy_), other.storage_.length_})
{}
: other.storage_.policy_);
storage_.length_ = other.storage_.length_;
}

Value::CZString::~CZString() {
if (cstr_ && storage_.policy_ == duplicate)
Expand Down

0 comments on commit 24f5449

Please sign in to comment.