From 6fb072f62c2f50118dd5cb377d10c76ece51e5fb Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 4 Oct 2020 14:36:07 +0200 Subject: Setze srcut-Marker... --- ringbuff.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ringbuff.c') diff --git a/ringbuff.c b/ringbuff.c index a963beb..c800f62 100644 --- a/ringbuff.c +++ b/ringbuff.c @@ -5,19 +5,24 @@ #include "util.h" +/* --8<-- ring_type */ typedef int T; struct ring_buffer { size_t head, tail; T array[8]; /* fit for your needs... */ }; +/* -->8-- */ +/* --8<-- ring_init */ void ring_init(struct ring_buffer *rb) { rb->head = rb->tail = 0; } +/* -->8-- */ +/* --8<-- ring_push_front */ bool ring_push_front(struct ring_buffer *rb, T data) { @@ -31,7 +36,9 @@ ring_push_front(struct ring_buffer *rb, T data) return true; } +/* -->8-- */ +/* --8<-- ring_push_back */ bool ring_push_back(struct ring_buffer *rb, T data) { @@ -45,7 +52,9 @@ ring_push_back(struct ring_buffer *rb, T data) return true; } +/* -->8-- */ +/* --8<-- ring_pop_front */ bool ring_pop_front(struct ring_buffer *rb, T *data) { @@ -59,7 +68,9 @@ ring_pop_front(struct ring_buffer *rb, T *data) return true; } +/* -->8-- */ +/* --8<-- ring_pop_back */ bool ring_pop_back(struct ring_buffer *rb, T *data) { @@ -73,18 +84,23 @@ ring_pop_back(struct ring_buffer *rb, T *data) return true; } +/* -->8-- */ +/* --8<-- ring_put */ bool ring_put(struct ring_buffer *rb, T data) { return ring_push_back(rb, data); } +/* -->8-- */ +/* --8<-- ring_get */ bool ring_get(struct ring_buffer *rb, T *data) { return ring_pop_front(rb, data); } +/* -->8-- */ void f() -- cgit v1.3