From 4fe272a7fbe45ab76f3af417d989c37fd4298ed1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Jul 2014 00:14:15 +0200 Subject: [PATCH] DecoderBuffer: add method _available() --- src/DecoderBuffer.cxx | 6 ++++++ src/DecoderBuffer.hxx | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/DecoderBuffer.cxx b/src/DecoderBuffer.cxx index 78a2ccdc6..4a5125bc5 100644 --- a/src/DecoderBuffer.cxx +++ b/src/DecoderBuffer.cxx @@ -130,6 +130,12 @@ decoder_buffer_fill(DecoderBuffer *buffer) return true; } +size_t +decoder_buffer_available(const DecoderBuffer *buffer) +{ + return buffer->length - buffer->consumed;; +} + const void * decoder_buffer_read(const DecoderBuffer *buffer, size_t *length_r) { diff --git a/src/DecoderBuffer.hxx b/src/DecoderBuffer.hxx index 0eaf0c4f3..65c6e0d2e 100644 --- a/src/DecoderBuffer.hxx +++ b/src/DecoderBuffer.hxx @@ -77,6 +77,13 @@ decoder_buffer_clear(DecoderBuffer *buffer); bool decoder_buffer_fill(DecoderBuffer *buffer); +/** + * How many bytes are stored in the buffer? + */ +gcc_pure +size_t +decoder_buffer_available(const DecoderBuffer *buffer); + /** * Reads data from the buffer. This data is not yet consumed, you * have to call decoder_buffer_consume() to do that. The returned