diff --git a/utils/messageqcpp/bytestream.h b/utils/messageqcpp/bytestream.h index f8453843e..3750a3e61 100644 --- a/utils/messageqcpp/bytestream.h +++ b/utils/messageqcpp/bytestream.h @@ -381,6 +381,11 @@ public: */ inline void rewind(); + /** + * Get the allocated size of the buffer. + */ + inline uint32_t getBufferSize() const; + /** * Serializeable interface */ @@ -390,7 +395,7 @@ public: * Serializeable interface */ EXPORT void deserialize(ByteStream& bs); - + /** * memory allocation chunk size */ @@ -529,6 +534,11 @@ inline ByteStream& ByteStream::operator=(const SBS& rhs) return *this; } +inline uint32_t ByteStream::getBufferSize() const +{ + return fMaxLen; +} + /** * stream a ByteStream out to any ostream */ diff --git a/utils/messageqcpp/bytestreampool.cpp b/utils/messageqcpp/bytestreampool.cpp index 833cdb3e8..765ac449a 100644 --- a/utils/messageqcpp/bytestreampool.cpp +++ b/utils/messageqcpp/bytestreampool.cpp @@ -73,8 +73,10 @@ void ByteStreamPool::returnByteStream(ByteStream *bs) boost::mutex::scoped_lock s(mutex); if (freeByteStream.size() > maxFreeBuffers) delete bs; - else + else { + bs->restart(); freeByteStreams.push_back(bs); + } } }