aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/fifo_buffer.c16
-rw-r--r--src/fifo_buffer.h13
2 files changed, 29 insertions, 0 deletions
diff --git a/src/fifo_buffer.c b/src/fifo_buffer.c
index 9ac7270bb..65cb2ffdc 100644
--- a/src/fifo_buffer.c
+++ b/src/fifo_buffer.c
@@ -66,6 +66,22 @@ fifo_buffer_free(struct fifo_buffer *buffer)
g_free(buffer);
}
+size_t
+fifo_buffer_capacity(const struct fifo_buffer *buffer)
+{
+ assert(buffer != NULL);
+
+ return buffer->size;
+}
+
+size_t
+fifo_buffer_available(const struct fifo_buffer *buffer)
+{
+ assert(buffer != NULL);
+
+ return buffer->end - buffer->start;
+}
+
void
fifo_buffer_clear(struct fifo_buffer *buffer)
{
diff --git a/src/fifo_buffer.h b/src/fifo_buffer.h
index 661dfd57e..114feec4c 100644
--- a/src/fifo_buffer.h
+++ b/src/fifo_buffer.h
@@ -63,6 +63,19 @@ void
fifo_buffer_free(struct fifo_buffer *buffer);
/**
+ * Return the capacity of the buffer, i.e. the size that was passed to
+ * fifo_buffer_new().
+ */
+size_t
+fifo_buffer_capacity(const struct fifo_buffer *buffer);
+
+/**
+ * Return the number of bytes currently stored in the buffer.
+ */
+size_t
+fifo_buffer_available(const struct fifo_buffer *buffer);
+
+/**
* Clears all data currently in this #fifo_buffer object. This does
* not overwrite the actuall buffer; it just resets the internal
* pointers.