diff --git a/container/SimpleRingBuffer.cpp b/container/SimpleRingBuffer.cpp index 3cc1ffdf..cad1a48e 100644 --- a/container/SimpleRingBuffer.cpp +++ b/container/SimpleRingBuffer.cpp @@ -2,16 +2,28 @@ #include SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld, - size_t maxExcessBytes) : + size_t maxExcessBytes) : RingBufferBase<>(0, size, overwriteOld), maxExcessBytes(maxExcessBytes) { + if(maxExcessBytes > size) { + this->maxExcessBytes = size; + } + else { + this->maxExcessBytes = maxExcessBytes; + } buffer = new uint8_t[size + maxExcessBytes]; } SimpleRingBuffer::SimpleRingBuffer(uint8_t *buffer, const size_t size, - bool overwriteOld, size_t maxExcessBytes): - RingBufferBase<>(0, size, overwriteOld), buffer(buffer), - maxExcessBytes(maxExcessBytes) {} + bool overwriteOld, size_t maxExcessBytes): + RingBufferBase<>(0, size, overwriteOld), buffer(buffer) { + if(maxExcessBytes > size) { + this->maxExcessBytes = size; + } + else { + this->maxExcessBytes = maxExcessBytes; + } +} SimpleRingBuffer::~SimpleRingBuffer() { diff --git a/container/SimpleRingBuffer.h b/container/SimpleRingBuffer.h index 4bb3a4e8..2627541f 100644 --- a/container/SimpleRingBuffer.h +++ b/container/SimpleRingBuffer.h @@ -111,7 +111,7 @@ public: private: static const uint8_t READ_PTR = 0; uint8_t* buffer = nullptr; - const size_t maxExcessBytes; + size_t maxExcessBytes; size_t excessBytes = 0; };