From d1792689f19f11a05d95de4b0a6ffb5280d2a6ee Mon Sep 17 00:00:00 2001 From: Eugene Shamaev Date: Sun, 2 Apr 2017 17:54:46 +0300 Subject: [PATCH] AP_HAL/utility: clear added to RingBuffer --- libraries/AP_HAL/utility/RingBuffer.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libraries/AP_HAL/utility/RingBuffer.h b/libraries/AP_HAL/utility/RingBuffer.h index 937c44b2c0..d24acba656 100644 --- a/libraries/AP_HAL/utility/RingBuffer.h +++ b/libraries/AP_HAL/utility/RingBuffer.h @@ -104,6 +104,12 @@ public: delete buffer; } + // Discards the buffer content, emptying it. + void clear(void) + { + buffer->clear(); + } + // return number of objects available to be read uint32_t available(void) const { return buffer->available() / sizeof(T); @@ -229,6 +235,12 @@ public: return true; } + // Discards the buffer content, emptying it. + void clear(void) + { + head = count = 0; + } + /* pop earliest object off the queue */