diff options
author | dzwdz | 2022-08-23 19:15:59 +0200 |
---|---|---|
committer | dzwdz | 2022-08-23 19:15:59 +0200 |
commit | 38cf66edaacc4e58b561bea8a77abfd3facf59fe (patch) | |
tree | 2e9ff33e195078fdcd454607082064e949b29bd4 /src/shared/container/ring.c | |
parent | 03c5dd9462492e291c6a49b88e1cd9ab34d86b6f (diff) |
shared/ring: rename ring_size to ring_used, add ring_avail
Diffstat (limited to 'src/shared/container/ring.c')
-rw-r--r-- | src/shared/container/ring.c | 6 |
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++) |