mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 22:30:30 +01:00
[apps/sequence][apps/graph] Reimplement checksum to avoid risking
overflowing the stack Change-Id: Ia2b70ceb174d70c20b0e7d635183a890629e4b24
This commit is contained in:
@@ -18,13 +18,13 @@ CartesianFunctionStore::CartesianFunctionStore() :
|
||||
}
|
||||
|
||||
uint32_t CartesianFunctionStore::storeChecksum() {
|
||||
size_t dataLengthInBytes = k_maxNumberOfFunctions*TextField::maxBufferSize()*sizeof(char);
|
||||
size_t dataLengthInBytes = k_maxNumberOfFunctions*sizeof(uint32_t);
|
||||
assert((dataLengthInBytes & 0x3) == 0); // Assert that dataLengthInBytes is a multiple of 4
|
||||
char data[k_maxNumberOfFunctions*TextField::maxBufferSize()] = {};
|
||||
uint32_t checksums[k_maxNumberOfFunctions];
|
||||
for (int i = 0; i < k_maxNumberOfFunctions; i++) {
|
||||
strlcpy(data+i*TextField::maxBufferSize(), m_functions[i].text(), TextField::maxBufferSize());
|
||||
checksums[i] = m_functions[i].checksum();
|
||||
}
|
||||
return Ion::crc32((uint32_t *)data, dataLengthInBytes>>2);
|
||||
return Ion::crc32((uint32_t *)checksums, dataLengthInBytes>>2);
|
||||
}
|
||||
|
||||
CartesianFunction * CartesianFunctionStore::functionAtIndex(int i) {
|
||||
|
||||
Reference in New Issue
Block a user