From c0435959dabc079cc172b344c4eec7647ed44077 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Tue, 6 Nov 2018 09:04:37 +0100 Subject: [PATCH] RingBuffer::decrease_write --- core/ring_buffer.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/ring_buffer.h b/core/ring_buffer.h index 25168800640..54486f8cadc 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -135,6 +135,12 @@ public: return p_n; }; + inline int decrease_write(int p_n) { + p_n = MIN(p_n, data_left()); + inc(write_pos, size_mask + 1 - p_n); + return p_n; + } + Error write(const T &p_v) { ERR_FAIL_COND_V(space_left() < 1, FAILED); data.write[inc(write_pos, 1)] = p_v;