keep track of max written in PacketPayload

This commit is contained in:
Stephen Birarda 2015-07-06 11:55:49 -07:00
parent b660c80988
commit 1867f259d6
2 changed files with 5 additions and 1 deletions

View file

@ -31,9 +31,12 @@ qint64 PacketPayload::writeData(const char* data, qint64 maxSize) {
// good to go - write the data
memcpy(_data + currentPos, src, srcBytes);
// should this cause us to push our index (is this the farthest we've written in data)?
// seek to the new position based on where our write just finished
seek(currentPos + srcBytes);
// keep track of _maxWritten so we can just write the actual data when packet is about to be sent
_maxWritten = std::max(pos() + 1, _maxWritten);
// return the number of bytes written
return srcBytes;
} else {

View file

@ -30,6 +30,7 @@ protected:
private:
char* _data;
qint64 _size = 0;
qint64 _maxWritten = 0;
};
#endif // hifi_PacketByteArray_h