diff --git a/utils/messageqcpp/bytestream.cpp b/utils/messageqcpp/bytestream.cpp index ce2679738..4e1dbd14d 100644 --- a/utils/messageqcpp/bytestream.cpp +++ b/utils/messageqcpp/bytestream.cpp @@ -545,6 +545,7 @@ void ByteStream::swap(ByteStream& rhs) std::swap(fCurInPtr, rhs.fCurInPtr); std::swap(fCurOutPtr, rhs.fCurOutPtr); std::swap(fMaxLen, rhs.fMaxLen); + std::swap(longStrings, rhs.longStrings); } ifstream& operator>>(ifstream& ifs, ByteStream& bs) @@ -564,7 +565,31 @@ bool ByteStream::operator==(const ByteStream& b) const if (b.length() != length()) return false; - return (memcmp(fCurOutPtr, b.fCurOutPtr, length()) == 0); + if (memcmp(fCurOutPtr, b.fCurOutPtr, length()) != 0) + return false; + + // Check the `longString` sizes. + if (longStrings.size() != b.longStrings.size()) + return false; + + // For each `longString`. + for (uint32_t i = 0, e = b.longStrings.size(); i < e; ++i) + { + const auto* leftMemChunk = reinterpret_cast(longStrings[i].get()); + const auto* rightMemChunk = reinterpret_cast(b.longStrings[i].get()); + if (leftMemChunk == nullptr || rightMemChunk == nullptr) + return false; + + const uint32_t leftSize = leftMemChunk->currentSize; + const uint32_t rightSize = rightMemChunk->currentSize; + if (leftSize != rightSize) + return false; + + if (memcmp(leftMemChunk->data, rightMemChunk->data, leftSize) != 0) + return false; + } + + return true; } bool ByteStream::operator!=(const ByteStream& b) const diff --git a/utils/messageqcpp/bytestream.h b/utils/messageqcpp/bytestream.h index ca6b03103..153d22d3b 100644 --- a/utils/messageqcpp/bytestream.h +++ b/utils/messageqcpp/bytestream.h @@ -471,6 +471,13 @@ protected: void doCopy(const ByteStream& rhs); private: + // Put struct `MemChunk` declaration here, to avoid circular dependency. + struct MemChunk + { + uint32_t currentSize; + uint32_t capacity; + uint8_t data[]; + }; uint8_t* fBuf; ///the start of the allocated buffer uint8_t* fCurInPtr; //the point in fBuf where data is inserted next diff --git a/utils/rowgroup/rowgroup.h b/utils/rowgroup/rowgroup.h index 97b652623..44a7fd532 100644 --- a/utils/rowgroup/rowgroup.h +++ b/utils/rowgroup/rowgroup.h @@ -177,6 +177,7 @@ public: // This is an overlay b/c the underlying data needs to be any size, // and alloc'd in one chunk. data can't be a separate dynamic chunk. + // NOTE: Change here, requires a change in 'bytestream.h'. struct MemChunk { uint32_t currentSize;