Lines Matching refs:rb
43 void ringbuffer_free(ringbuffer_t *rb) { in ringbuffer_free() argument
44 if (rb != NULL) in ringbuffer_free()
45 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 assert(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 assert(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 assert(rb); in ringbuffer_insert()
63 if (length > ringbuffer_available(rb)) in ringbuffer_insert()
64 length = ringbuffer_available(rb); in ringbuffer_insert()
67 *rb->tail++ = *p++; in ringbuffer_insert()
68 if (rb->tail >= (rb->base + rb->total)) in ringbuffer_insert()
69 rb->tail = rb->base; in ringbuffer_insert()
72 rb->available -= length; in ringbuffer_insert()
76 size_t ringbuffer_delete(ringbuffer_t *rb, size_t length) { in ringbuffer_delete() argument
77 assert(rb); in ringbuffer_delete()
79 if (length > ringbuffer_size(rb)) in ringbuffer_delete()
80 length = ringbuffer_size(rb); in ringbuffer_delete()
82 rb->head += length; in ringbuffer_delete()
83 if (rb->head >= (rb->base + rb->total)) in ringbuffer_delete()
84 rb->head -= rb->total; in ringbuffer_delete()
86 rb->available += length; in ringbuffer_delete()
90 size_t ringbuffer_peek(const ringbuffer_t *rb, off_t offset, uint8_t *p, size_t length) { in ringbuffer_peek() argument
91 assert(rb); in ringbuffer_peek()
94 assert((size_t)offset <= ringbuffer_size(rb)); in ringbuffer_peek()
96 uint8_t *b = ((rb->head - rb->base + offset) % rb->total) + rb->base; in ringbuffer_peek()
97 …const size_t bytes_to_copy = (offset + length > ringbuffer_size(rb)) ? ringbuffer_size(rb) - offse… in ringbuffer_peek()
101 if (b >= (rb->base + rb->total)) in ringbuffer_peek()
102 b = rb->base; in ringbuffer_peek()
108 size_t ringbuffer_pop(ringbuffer_t *rb, uint8_t *p, size_t length) { in ringbuffer_pop() argument
109 assert(rb); in ringbuffer_pop()
112 const size_t copied = ringbuffer_peek(rb, 0, p, length); in ringbuffer_pop()
113 rb->head += copied; in ringbuffer_pop()
114 if (rb->head >= (rb->base + rb->total)) in ringbuffer_pop()
115 rb->head -= rb->total; in ringbuffer_pop()
117 rb->available += copied; in ringbuffer_pop()