diff --git a/apps/sequence/sequence.cpp b/apps/sequence/sequence.cpp index e700ce607..5155d1069 100644 --- a/apps/sequence/sequence.cpp +++ b/apps/sequence/sequence.cpp @@ -87,6 +87,9 @@ uint32_t Sequence::checksum() { strlcpy(data, text(), TextField::maxBufferSize()); strlcpy(data+TextField::maxBufferSize(), firstInitialConditionText(), TextField::maxBufferSize()); strlcpy(data+2*TextField::maxBufferSize(), secondInitialConditionText(), TextField::maxBufferSize()); + data[k_dataLengthInBytes-3] = (char)m_type; + data[k_dataLengthInBytes-2] = name()!= nullptr ? name()[0] : 0; + data[k_dataLengthInBytes-1] = isActive() ? 1 : 0; return Ion::crc32((uint32_t *)data, k_dataLengthInBytes>>2); } diff --git a/apps/sequence/sequence.h b/apps/sequence/sequence.h index 359118379..42c58661d 100644 --- a/apps/sequence/sequence.h +++ b/apps/sequence/sequence.h @@ -43,7 +43,7 @@ public: private: constexpr static int k_maxRecurrentRank = 10000; constexpr static float k_maxNumberOfTermsInSum = 100000.0f; - constexpr static size_t k_dataLengthInBytes = 3*TextField::maxBufferSize()*sizeof(char); + constexpr static size_t k_dataLengthInBytes = (3*TextField::maxBufferSize()+3)*sizeof(char)+1; static_assert((k_dataLengthInBytes & 0x3) == 0, "The sequence data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4 char symbol() const override; Type m_type; diff --git a/apps/shared/function.cpp b/apps/shared/function.cpp index 7e73f7fd2..541a92ba6 100644 --- a/apps/shared/function.cpp +++ b/apps/shared/function.cpp @@ -29,6 +29,8 @@ Function& Function::operator=(const Function& other) { uint32_t Function::checksum() { char data[k_dataLengthInBytes/sizeof(char)] = {}; strlcpy(data, m_text, TextField::maxBufferSize()); + data[k_dataLengthInBytes-2] = m_name != nullptr ? m_name[0] : 0; + data[k_dataLengthInBytes-1] = m_active ? 1 : 0; return Ion::crc32((uint32_t *)data, k_dataLengthInBytes>>2); } diff --git a/apps/shared/function.h b/apps/shared/function.h index f03d75fb6..aadd1024f 100644 --- a/apps/shared/function.h +++ b/apps/shared/function.h @@ -32,7 +32,7 @@ public: protected: mutable Poincare::Expression * m_expression; private: - constexpr static size_t k_dataLengthInBytes = TextField::maxBufferSize()*sizeof(char); + constexpr static size_t k_dataLengthInBytes = (TextField::maxBufferSize()+2)*sizeof(char)+2; static_assert((k_dataLengthInBytes & 0x3) == 0, "The function data size is not a multiple of 4 bytes (cannot compute crc)"); // Assert that dataLengthInBytes is a multiple of 4 virtual char symbol() const = 0; char m_text[TextField::maxBufferSize()];