summaryrefslogtreecommitdiff
path: root/src/shared/container/ring.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/container/ring.c')
-rw-r--r--src/shared/container/ring.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/shared/container/ring.c b/src/shared/container/ring.c
index 67944b0..21c63a1 100644
--- a/src/shared/container/ring.c
+++ b/src/shared/container/ring.c
@@ -7,13 +7,17 @@ static bool at_end(ring_t *r) {
|| (r->_head + 1 == r->capacity && r->_tail == 0);
}
-size_t ring_size(ring_t *r) {
+size_t ring_used(ring_t *r) {
if (r->_head >= r->_tail)
return r->_head - r->_tail;
else
return r->_head + r->capacity - r->_tail;
}
+size_t ring_avail(ring_t *r) {
+ return r->capacity - ring_used(r);
+}
+
void ring_put(ring_t *r, void *buf, size_t len) {
// TODO do something similar to ring_get
for (size_t i = 0; i < len; i++)