From e9b931b857f5c69782909be6301f77fa463596a4 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 24 Apr 2022 18:25:27 +0200 Subject: [PATCH] fix full flag --- ringbuffer.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ringbuffer.c b/ringbuffer.c index c90bbe2..c4c251e 100644 --- a/ringbuffer.c +++ b/ringbuffer.c @@ -21,21 +21,15 @@ void freeRingbuffer(ringbuffer *buf) void addValue(ringbuffer *buf, int value) { - if (buf->count >= buf->max) { - buf->count = buf->max; - buf->full = true; - buf->tail++; - } - - if (buf->tail >= buf->max) - buf->tail = 0; - if (buf->head >= buf->max) buf->head = 0; buf->position[buf->head] = value; buf->head++; buf->count++; + + if (buf->count >= buf->max) + buf->full = true; } int getValue(ringbuffer *buf) -- 2.39.5