From bf3276cbb2545c1773b1478569703dda9bb402d1 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Thu, 1 Oct 2020 20:40:02 +0200 Subject: [PATCH] taken over master --- container/RingBufferBase.h | 8 ++++---- container/SimpleRingBuffer.cpp | 6 +----- container/SimpleRingBuffer.h | 9 +++++---- container/SinglyLinkedList.h | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/container/RingBufferBase.h b/container/RingBufferBase.h index 243a2915..886b9fab 100644 --- a/container/RingBufferBase.h +++ b/container/RingBufferBase.h @@ -1,5 +1,5 @@ -#ifndef FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ -#define FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ +#ifndef FSFW_CONTAINER_RINGBUFFERBASE_H_ +#define FSFW_CONTAINER_RINGBUFFERBASE_H_ #include "../returnvalues/HasReturnvaluesIF.h" #include @@ -65,6 +65,7 @@ protected: size_t read[N_READ_PTRS]; const size_t size; const bool overwriteOld; + void incrementWrite(uint32_t amount) { write = ((write + amount - start) % size) + start; } @@ -90,7 +91,6 @@ protected: } } - size_t getRead(uint8_t n = 0) const { return read[n]; } @@ -110,4 +110,4 @@ protected: } }; -#endif /* FRAMEWORK_CONTAINER_RINGBUFFERBASE_H_ */ +#endif /* FSFW_CONTAINER_RINGBUFFERBASE_H_ */ diff --git a/container/SimpleRingBuffer.cpp b/container/SimpleRingBuffer.cpp index d6b6f5af..88c9290e 100644 --- a/container/SimpleRingBuffer.cpp +++ b/container/SimpleRingBuffer.cpp @@ -1,4 +1,4 @@ -#include "../container/SimpleRingBuffer.h" +#include "SimpleRingBuffer.h" #include SimpleRingBuffer::SimpleRingBuffer(const size_t size, bool overwriteOld, @@ -25,12 +25,10 @@ SimpleRingBuffer::SimpleRingBuffer(uint8_t *buffer, const size_t size, } } - SimpleRingBuffer::~SimpleRingBuffer() { delete[] buffer; } - ReturnValue_t SimpleRingBuffer::getFreeElement(uint8_t **writePointer, size_t amount) { if (availableWriteSpace() >= amount or overwriteOld) { @@ -131,5 +129,3 @@ ReturnValue_t SimpleRingBuffer::deleteData(size_t amount, incrementRead(amount, READ_PTR); return HasReturnvaluesIF::RETURN_OK; } - - diff --git a/container/SimpleRingBuffer.h b/container/SimpleRingBuffer.h index dcf2684b..37ad5679 100644 --- a/container/SimpleRingBuffer.h +++ b/container/SimpleRingBuffer.h @@ -1,7 +1,7 @@ -#ifndef FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ -#define FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ +#ifndef FSFW_CONTAINER_SIMPLERINGBUFFER_H_ +#define FSFW_CONTAINER_SIMPLERINGBUFFER_H_ -#include "../container/RingBufferBase.h" +#include "RingBufferBase.h" #include /** @@ -117,6 +117,7 @@ public: */ ReturnValue_t deleteData(size_t amount, bool deleteRemaining = false, size_t* trueAmount = nullptr); + private: static const uint8_t READ_PTR = 0; uint8_t* buffer = nullptr; @@ -124,5 +125,5 @@ private: size_t excessBytes = 0; }; -#endif /* FRAMEWORK_CONTAINER_SIMPLERINGBUFFER_H_ */ +#endif /* FSFW_CONTAINER_SIMPLERINGBUFFER_H_ */ diff --git a/container/SinglyLinkedList.h b/container/SinglyLinkedList.h index 7d5fc4a9..eb6ae276 100644 --- a/container/SinglyLinkedList.h +++ b/container/SinglyLinkedList.h @@ -100,7 +100,7 @@ public: */ ElementIterator back() const { LinkedElement *element = start; - while (element != nullptr) { + while (element->getNext() != nullptr) { element = element->getNext(); } return ElementIterator::Iterator(element);