40#ifndef RINGBUFINDEX_H_
41#define RINGBUFINDEX_H_
48 uint8_t put_ptr, get_ptr;
110 return (r->put_ptr - r->get_ptr) & r->mask;
121 return ((r->put_ptr - r->get_ptr) & r->mask) == r->mask;
static int ringbufindex_size(const struct ringbufindex *r)
Return the ring buffer size.
int ringbufindex_peek_get(const struct ringbufindex *r)
Return the index of the first element which will be removed if calling ringbufindex_get.
static int ringbufindex_elements(const struct ringbufindex *r)
Return the number of elements currently in the ring buffer.
void ringbufindex_init(struct ringbufindex *r, uint8_t size)
Initialize a ring buffer.
int ringbufindex_put(struct ringbufindex *r)
Put one element to the ring buffer.
int ringbufindex_get(struct ringbufindex *r)
Remove the first element and return its index.
static int ringbufindex_full(const struct ringbufindex *r)
Is the ring buffer full?
int ringbufindex_peek_put(const struct ringbufindex *r)
Check if there is space to put an element.
static int ringbufindex_empty(const struct ringbufindex *r)
Is the ring buffer empty?