aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util/CircularBuffer.hxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/CircularBuffer.hxx b/src/util/CircularBuffer.hxx
index 0321b91f6..da6f412a5 100644
--- a/src/util/CircularBuffer.hxx
+++ b/src/util/CircularBuffer.hxx
@@ -108,6 +108,18 @@ public:
}
/**
+ * Returns the number of elements that can be added to this
+ * buffer.
+ */
+ constexpr size_type GetSpace() const {
+ /* space = capacity - size - 1 */
+ return (head <= tail
+ ? capacity - tail + head
+ : head - tail)
+ - 1;
+ }
+
+ /**
* Prepares writing. Returns a buffer range which may be written.
* When you are finished, call Append().
*/