Lines Matching refs:rb

44 void ringbuffer_free(ringbuffer_t* rb) {  in ringbuffer_free()  argument
45 if (rb != NULL) osi_free(rb->base); in ringbuffer_free()
46 osi_free(rb); in ringbuffer_free()
49 size_t ringbuffer_available(const ringbuffer_t* rb) { in ringbuffer_available() argument
50 CHECK(rb); in ringbuffer_available()
51 return rb->available; in ringbuffer_available()
54 size_t ringbuffer_size(const ringbuffer_t* rb) { in ringbuffer_size() argument
55 CHECK(rb); in ringbuffer_size()
56 return rb->total - rb->available; in ringbuffer_size()
59 size_t ringbuffer_insert(ringbuffer_t* rb, const uint8_t* p, size_t length) { in ringbuffer_insert() argument
60 CHECK(rb); in ringbuffer_insert()
63 if (length > ringbuffer_available(rb)) length = ringbuffer_available(rb); in ringbuffer_insert()
66 *rb->tail++ = *p++; in ringbuffer_insert()
67 if (rb->tail >= (rb->base + rb->total)) rb->tail = rb->base; in ringbuffer_insert()
70 rb->available -= length; in ringbuffer_insert()
74 size_t ringbuffer_delete(ringbuffer_t* rb, size_t length) { in ringbuffer_delete() argument
75 CHECK(rb); in ringbuffer_delete()
77 if (length > ringbuffer_size(rb)) length = ringbuffer_size(rb); in ringbuffer_delete()
79 rb->head += length; in ringbuffer_delete()
80 if (rb->head >= (rb->base + rb->total)) rb->head -= rb->total; in ringbuffer_delete()
82 rb->available += length; in ringbuffer_delete()
86 size_t ringbuffer_peek(const ringbuffer_t* rb, off_t offset, uint8_t* p, in ringbuffer_peek() argument
88 CHECK(rb); in ringbuffer_peek()
91 CHECK((size_t)offset <= ringbuffer_size(rb)); in ringbuffer_peek()
93 uint8_t* b = ((rb->head - rb->base + offset) % rb->total) + rb->base; in ringbuffer_peek()
94 const size_t bytes_to_copy = (offset + length > ringbuffer_size(rb)) in ringbuffer_peek()
95 ? ringbuffer_size(rb) - offset in ringbuffer_peek()
100 if (b >= (rb->base + rb->total)) b = rb->base; in ringbuffer_peek()
106 size_t ringbuffer_pop(ringbuffer_t* rb, uint8_t* p, size_t length) { in ringbuffer_pop() argument
107 CHECK(rb); in ringbuffer_pop()
110 const size_t copied = ringbuffer_peek(rb, 0, p, length); in ringbuffer_pop()
111 rb->head += copied; in ringbuffer_pop()
112 if (rb->head >= (rb->base + rb->total)) rb->head -= rb->total; in ringbuffer_pop()
114 rb->available += copied; in ringbuffer_pop()