Commit 08fee9a2 authored by Max Kellermann's avatar Max Kellermann

util/ForeignFifoBuffer: add method GetAvailable()

parent f89da178
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
using ForeignFifoBuffer<T>::IsEmpty; using ForeignFifoBuffer<T>::IsEmpty;
using ForeignFifoBuffer<T>::IsFull; using ForeignFifoBuffer<T>::IsFull;
using ForeignFifoBuffer<T>::GetAvailable;
using ForeignFifoBuffer<T>::Read; using ForeignFifoBuffer<T>::Read;
using ForeignFifoBuffer<T>::Consume; using ForeignFifoBuffer<T>::Consume;
using ForeignFifoBuffer<T>::Write; using ForeignFifoBuffer<T>::Write;
...@@ -73,7 +74,7 @@ public: ...@@ -73,7 +74,7 @@ public:
/* we already have enough space */ /* we already have enough space */
return; return;
const size_type in_use = Read().size; const size_type in_use = GetAvailable();
const size_type required_capacity = in_use + n; const size_type required_capacity = in_use + n;
size_type new_capacity = GetCapacity(); size_type new_capacity = GetCapacity();
do { do {
......
...@@ -171,6 +171,10 @@ public: ...@@ -171,6 +171,10 @@ public:
tail += n; tail += n;
} }
constexpr size_type GetAvailable() const {
return tail - head;
}
/** /**
* Return a buffer range which may be read. The buffer pointer is * Return a buffer range which may be read. The buffer pointer is
* writable, to allow modifications while parsing. * writable, to allow modifications while parsing.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment