diff options
author | Max Kellermann <max@duempel.org> | 2011-11-27 21:11:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-11-27 21:11:47 +0100 |
commit | a85af593f170f4081b44157d82e746ddc12cdc91 (patch) | |
tree | 1c5319c02c1345c8e730f2f9151ee3a2d593e30c | |
parent | 07067f8b958d52699526f4f757bca2714da183f4 (diff) | |
download | mpd-a85af593f170f4081b44157d82e746ddc12cdc91.tar.gz mpd-a85af593f170f4081b44157d82e746ddc12cdc91.tar.xz mpd-a85af593f170f4081b44157d82e746ddc12cdc91.zip |
fifo_buffer: add functions _capacity() and _available()
-rw-r--r-- | src/fifo_buffer.c | 16 | ||||
-rw-r--r-- | src/fifo_buffer.h | 13 |
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. |