Core/PoolByteStream: Fix pool returning on Reset
This commit is contained in:
parent
50ed8b4028
commit
45c947faf1
|
|
@ -18,8 +18,6 @@ namespace Nz
|
|||
|
||||
class NAZARA_CORE_API PoolByteStream : public ByteStream
|
||||
{
|
||||
friend class Network;
|
||||
|
||||
public:
|
||||
inline PoolByteStream(ByteArrayPool& pool);
|
||||
inline PoolByteStream(ByteArrayPool& pool, std::size_t capacity);
|
||||
|
|
|
|||
|
|
@ -28,9 +28,13 @@ namespace Nz
|
|||
void PoolByteStream::Reset(std::size_t capacity)
|
||||
{
|
||||
if (m_buffer.GetCapacity() < capacity)
|
||||
m_buffer = m_pool.GetByteArray(capacity);
|
||||
{
|
||||
if (m_buffer.GetCapacity() > 0)
|
||||
m_pool.ReturnByteArray(std::move(m_buffer));
|
||||
|
||||
SetStream(&m_buffer, Nz::OpenMode_ReadWrite);
|
||||
m_buffer = m_pool.GetByteArray(capacity);
|
||||
SetStream(&m_buffer, Nz::OpenMode_ReadWrite);
|
||||
}
|
||||
}
|
||||
|
||||
void PoolByteStream::OnEmptyStream()
|
||||
|
|
|
|||
Loading…
Reference in New Issue