mirror of
https://github.com/thelsing/knx.git
synced 2025-05-16 01:16:18 +02:00
Merge pull request #314 from Phil1pp/clear-memory
Clear memory if reading/writing of tableobjects fails
This commit is contained in:
commit
0102ed23da
@ -180,6 +180,7 @@ void Memory::writeMemory()
|
||||
if (block == nullptr)
|
||||
{
|
||||
println("_data of TableObject not in _usedList");
|
||||
clearMemory();
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -199,6 +200,12 @@ void Memory::saveMemory()
|
||||
_platform.commitNonVolatileMemory();
|
||||
}
|
||||
|
||||
void Memory::clearMemory()
|
||||
{
|
||||
_platform.writeNonVolatileMemory(0, 0xFF, _metadataSize);
|
||||
_platform.commitNonVolatileMemory();
|
||||
}
|
||||
|
||||
void Memory::addSaveRestore(SaveRestore* obj)
|
||||
{
|
||||
if (_saveCount >= MAXSAVE - 1)
|
||||
@ -288,6 +295,7 @@ void Memory::freeMemory(uint8_t* ptr)
|
||||
if (!found)
|
||||
{
|
||||
println("freeMemory for not used pointer called");
|
||||
clearMemory();
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -329,6 +337,7 @@ MemoryBlock* Memory::removeFromList(MemoryBlock* head, MemoryBlock* item)
|
||||
if (!head || !item)
|
||||
{
|
||||
println("invalid parameters of Memory::removeFromList");
|
||||
clearMemory();
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -350,6 +359,7 @@ MemoryBlock* Memory::removeFromList(MemoryBlock* head, MemoryBlock* item)
|
||||
if (!found)
|
||||
{
|
||||
println("tried to remove block from list not in it");
|
||||
clearMemory();
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
@ -476,12 +486,14 @@ void Memory::addNewUsedBlock(uint8_t* address, size_t size)
|
||||
if (smallerFreeBlock == nullptr)
|
||||
{
|
||||
println("addNewUsedBlock: no smallerBlock found");
|
||||
clearMemory();
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
if ((smallerFreeBlock->address + smallerFreeBlock->size) < (address + size))
|
||||
{
|
||||
println("addNewUsedBlock: found block can't contain new block");
|
||||
clearMemory();
|
||||
_platform.fatalError();
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ class Memory
|
||||
void readMemory();
|
||||
void writeMemory();
|
||||
void saveMemory();
|
||||
void clearMemory();
|
||||
void addSaveRestore(SaveRestore* obj);
|
||||
void addSaveRestore(TableObject* obj);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user