From 28a60dcf1abefc3170e6cf31bd9208802e162864 Mon Sep 17 00:00:00 2001 From: Hector van der Aa Date: Sun, 10 May 2026 15:11:16 +0200 Subject: [PATCH] Fixed ring buffer incrementation bug --- src/base/ring_buffer.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base/ring_buffer.h b/src/base/ring_buffer.h index 5a0e8ef..29abd05 100644 --- a/src/base/ring_buffer.h +++ b/src/base/ring_buffer.h @@ -18,7 +18,8 @@ class RingBuffer { } buffer_[head_] = item; - head_ = (head_++) % SIZE; + // DO NOT use head_++ this creates an incrementation bug where head_ never goes above 0 + head_ = (head_ + 1) % SIZE; count_++; return 0; } @@ -28,7 +29,8 @@ class RingBuffer { } item = buffer_[tail_]; - tail_ = (tail_++) % SIZE; + // DO NOT use tail_++ this creates an incrementation bug where tail_ never goes above 0 + tail_ = (tail_ + 1) % SIZE; count_--; return 0; }