diff options
author | Michał Łyszczek <michal.lyszczek@gmail.com> | 2016-12-17 20:43:57 +0100 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@gmail.com> | 2016-12-17 20:43:57 +0100 |
commit | c0a3a2daf0f601f4e8911fc0e12716bdbcb4e5f1 (patch) | |
tree | 11e49dddc5b50ae26b86fc2a8a5e634871425db2 /rb.c | |
parent | ff6d4c3c74b70e3e1a96cf99a0b6e5817a8a4002 (diff) | |
download | librb-c0a3a2daf0f601f4e8911fc0e12716bdbcb4e5f1.tar.gz librb-c0a3a2daf0f601f4e8911fc0e12716bdbcb4e5f1.tar.bz2 librb-c0a3a2daf0f601f4e8911fc0e12716bdbcb4e5f1.zip |
Function rb_space/count made public
Diffstat (limited to 'rb.c')
-rw-r--r-- | rb.c | 51 |
1 files changed, 27 insertions, 24 deletions
@@ -25,30 +25,6 @@ ****************************************************************************/ /***************************************************************************** - * Name: rb_count - * - * Description: - * Calculates number of elements in ring buffer - ****************************************************************************/ - -static size_t rb_count(const struct rb *rb) -{ - return (rb->head - rb->tail) & (rb->count - 1); -} - -/***************************************************************************** - * Name: rb_space - * - * Description: - * Calculates how many elements can be pushed into ring buffer - ****************************************************************************/ - -static size_t rb_space(const struct rb *rb) -{ - return (rb->tail - (rb->head + 1)) & (rb->count -1 ); -} - -/***************************************************************************** * Name: rb_count_end * * Description: @@ -702,6 +678,7 @@ int rb_clear(struct rb *rb) rb->head = 0; rb->tail = 0; + return 0; } /***************************************************************************** @@ -800,3 +777,29 @@ const char *rb_version(char *major, char *minor, char *patch) return VERSION; } + +/***************************************************************************** + * Name: rb_count + * + * Description: + * Calculates number of elements in ring buffer + ****************************************************************************/ + +size_t rb_count(const struct rb *rb) +{ + return (rb->head - rb->tail) & (rb->count - 1); +} + +/***************************************************************************** + * Name: rb_space + * + * Description: + * Calculates how many elements can be pushed into ring buffer + ****************************************************************************/ + +size_t rb_space(const struct rb *rb) +{ + return (rb->tail - (rb->head + 1)) & (rb->count -1 ); +} + + |