diff --git a/apps/graph/values/values_controller.h b/apps/graph/values/values_controller.h index 6b3095995..0ee8087fc 100644 --- a/apps/graph/values/values_controller.h +++ b/apps/graph/values/values_controller.h @@ -72,10 +72,12 @@ private: Shared::ContinuousFunction::PlotType plotTypeAtColumn(int * i) const; // Function evaluation memoization + static constexpr int k_valuesCellBufferSize = 2*Poincare::PrintFloat::charSizeForFloatsWithPrecision(Poincare::Preferences::LargeNumberOfSignificantDigits)+3; // The largest buffer holds (-1.234567E-123;-1.234567E-123) char * memoizedBufferAtIndex(int i) override { assert(i >= 0 && i < k_maxNumberOfCells); return m_memoizedBuffer[i]; } + int valuesCellBufferSize() const override { return k_valuesCellBufferSize; } int numberOfMemoizedColumn() override { return k_maxNumberOfFunctions; } /* The conversion of column coordinates from the absolute table to the table * on only values cell depends on the number of abscissa columns which depends diff --git a/apps/sequence/values/values_controller.h b/apps/sequence/values/values_controller.h index 1b38169d9..940f92a29 100644 --- a/apps/sequence/values/values_controller.h +++ b/apps/sequence/values/values_controller.h @@ -46,10 +46,12 @@ private: Shared::Interval * intervalAtColumn(int columnIndex) override; // Function evaluation memoization + static constexpr int k_valuesCellBufferSize = Poincare::PrintFloat::charSizeForFloatsWithPrecision(Poincare::Preferences::LargeNumberOfSignificantDigits); char * memoizedBufferAtIndex(int i) override { assert(i >= 0 && i < k_maxNumberOfCells); return m_memoizedBuffer[i]; } + int valuesCellBufferSize() const override{ return k_valuesCellBufferSize; } int numberOfMemoizedColumn() override { return k_maxNumberOfSequences; } void fillMemoizedBuffer(int i, int j, int index) override; diff --git a/apps/shared/values_controller.cpp b/apps/shared/values_controller.cpp index b35b67745..b9750eeee 100644 --- a/apps/shared/values_controller.cpp +++ b/apps/shared/values_controller.cpp @@ -263,7 +263,7 @@ void ValuesController::resetMemoization() { } void ValuesController::moveMemoizedBuffer(int destinationI, int destinationJ, int sourceI, int sourceJ) { - strlcpy(memoizedBufferAtIndex(destinationJ*numberOfMemoizedColumn() + destinationI), memoizedBufferAtIndex(sourceJ*numberOfMemoizedColumn() + sourceI), k_valuesCellBufferSize); + strlcpy(memoizedBufferAtIndex(destinationJ*numberOfMemoizedColumn() + destinationI), memoizedBufferAtIndex(sourceJ*numberOfMemoizedColumn() + sourceI), valuesCellBufferSize()); } char * ValuesController::memoizedBufferForCell(int i, int j) { diff --git a/apps/shared/values_controller.h b/apps/shared/values_controller.h index 425ef0b8b..16a055384 100644 --- a/apps/shared/values_controller.h +++ b/apps/shared/values_controller.h @@ -81,7 +81,6 @@ protected: * the titles and the abscissa columns) * - the memoized table (which is a subset of the table of values cells) */ - static constexpr int k_valuesCellBufferSize = 2*Poincare::PrintFloat::charSizeForFloatsWithPrecision(Poincare::Preferences::LargeNumberOfSignificantDigits)+3; // The largest buffer holds (-1.234567E-123;-1.234567E-123) void resetMemoization(); virtual char * memoizedBufferAtIndex(int i) = 0; virtual int numberOfMemoizedColumn() = 0; @@ -106,6 +105,7 @@ private: int absoluteRowForValuesRow(int row) { return row + 1; } // Add the title row // Coordinates of memoizedBufferForCell refer to the absolute table char * memoizedBufferForCell(int i, int j); + virtual int valuesCellBufferSize() const = 0; // Coordinates of moveMemoizedBuffer refer to the memoized table void moveMemoizedBuffer(int destinationI, int destinationJ, int sourceI, int sourceJ); // Coordinates of fillMemoizedBuffer refer to the absolute table but the index