mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 19:10:20 +01:00
Make next() use call to begin() instead of _buffer.begin()
This commit is contained in:
@@ -284,7 +284,7 @@ public:
|
||||
std::size_t available() const
|
||||
/// Returns the size of the available portion of the buffer.
|
||||
{
|
||||
return _buffer.size() - _used;
|
||||
return size() - _used;
|
||||
}
|
||||
|
||||
void drain(std::size_t length = 0)
|
||||
@@ -361,6 +361,9 @@ public:
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (_begin != 0)
|
||||
{
|
||||
// Move the data to the start of the buffer so begin() and next()
|
||||
// always return consistent pointers with each other and allow writing
|
||||
// to the end of the buffer.
|
||||
std::memmove(_buffer.begin(), _buffer.begin() + _begin, _used * sizeof(T));
|
||||
_begin = 0;
|
||||
}
|
||||
@@ -371,16 +374,7 @@ public:
|
||||
/// Returns the pointer to the next available position in the buffer.
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
if (available() == 0)
|
||||
throw InvalidAccessException("Buffer is full.");
|
||||
|
||||
if (_begin != 0)
|
||||
{
|
||||
std::memmove(_buffer.begin(), _buffer.begin() + _begin, _used * sizeof(T));
|
||||
_begin = 0;
|
||||
}
|
||||
|
||||
return _buffer.begin() + _used;
|
||||
return begin() + _used;
|
||||
}
|
||||
|
||||
T& operator [] (std::size_t index)
|
||||
|
||||
Reference in New Issue
Block a user