taken over master

This commit is contained in:
Robin Müller 2020-10-01 20:40:02 +02:00
parent 148bbb4be4
commit bf3276cbb2
4 changed files with 11 additions and 14 deletions

View File

@ -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 <cstddef>
@ -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_ */

View File

@ -1,4 +1,4 @@
#include "../container/SimpleRingBuffer.h"
#include "SimpleRingBuffer.h"
#include <cstring>
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;
}

View File

@ -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 <cstddef>
/**
@ -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_ */

View File

@ -100,7 +100,7 @@ public:
*/
ElementIterator back() const {
LinkedElement<T> *element = start;
while (element != nullptr) {
while (element->getNext() != nullptr) {
element = element->getNext();
}
return ElementIterator::Iterator(element);