aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/outputBuffer.c')
-rw-r--r--src/outputBuffer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index f6fb38937..aadd5e379 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -62,12 +62,17 @@ int outputBufferEmpty(const OutputBuffer * cb)
return cb->begin == cb->end;
}
-unsigned availableOutputBuffer(const OutputBuffer * cb)
+unsigned int outputBufferRelative(const OutputBuffer * cb, unsigned i)
{
- if (cb->end >= cb->begin)
- return cb->end - cb->begin;
+ if (i >= cb->begin)
+ return i - cb->begin;
else
- return cb->end + buffered_chunks - cb->begin;
+ return i + buffered_chunks - cb->begin;
+}
+
+unsigned availableOutputBuffer(const OutputBuffer * cb)
+{
+ return outputBufferRelative(cb, cb->end);
}
int outputBufferAbsolute(const OutputBuffer * cb, unsigned relative)