[apps/calculation] Correct error in ring buffer methods

Change-Id: I684afe462d23384a4807644586c03ea654ed7c8a
This commit is contained in:
Émilie Feral
2016-10-28 11:58:59 +02:00
parent ac6bdee979
commit dba85cc56a
2 changed files with 9 additions and 6 deletions

View File

@@ -20,16 +20,17 @@ Calculation * CalculationStore::push(Calculation * c) {
Calculation * CalculationStore::calculationAtIndex(int i) {
int j = 0;
Calculation * currentCalc = m_start;
while (j<=i) {
Calculation * previousCalc = nullptr;
while (j <= i) {
if (!currentCalc++->isEmpty()) {
previousCalc = currentCalc - 1;
j++;
}
if (currentCalc >= m_calculations + k_maxNumberOfCalculations) {
currentCalc = m_calculations;
}
if (!currentCalc->isEmpty()) {
j++;
}
currentCalc++;
}
return currentCalc-1;
return previousCalc;
}
int CalculationStore::numberOfCalculations() {

View File

@@ -5,6 +5,8 @@
namespace Calculation {
// TODO: make tests for the ring buffer
class CalculationStore {
public:
CalculationStore();