From 03c9475bc378171a1018c4e56cc453844ddd2b08 Mon Sep 17 00:00:00 2001 From: Oxore Date: Thu, 9 Mar 2023 02:32:59 +0300 Subject: Rewrite ring buffer loops Somehow the loops turned out to be infinite. --- app/platform/stm32f0-gcc/ring_buffer.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/platform/stm32f0-gcc/ring_buffer.h b/app/platform/stm32f0-gcc/ring_buffer.h index 1a065ef..ae4d99d 100644 --- a/app/platform/stm32f0-gcc/ring_buffer.h +++ b/app/platform/stm32f0-gcc/ring_buffer.h @@ -20,7 +20,11 @@ public: } constexpr void Push(const UnitType *items, size_t nitems) { - if (items) for (; nitems; items++, nitems--) Push(*items); + if (items) { + for (size_t i = 0; i < nitems; i++) { + Push(items[i]); + } + } } constexpr UnitType Pop() { @@ -30,7 +34,11 @@ public: } constexpr void Pop(UnitType* buf, size_t nitems) { - if (buf) for (; nitems; nitems--, buf++) *buf = Pop(); + if (buf) { + for (size_t i = 0; i < nitems; i++) { + buf[i] = Pop(); + } + } } constexpr size_t Free() { -- cgit v1.2.3