Remove specific panic codes for ref-counting.

This commit is contained in:
Michal Moskal 2015-10-27 08:28:06 -07:00
parent 59853855b0
commit 3900962556
2 changed files with 4 additions and 12 deletions

View file

@ -22,12 +22,6 @@ enum Error{
MICROBIT_OOM = 20,
// Corruption detected in the micro:bit heap space
MICROBIT_HEAP_ERROR = 30,
// refcounter on an object is invalid (memory corruption)
MICROBIT_REF_COUNT_CORRUPTION = 31,
// refcounter was incremented/decremented after it already reached zero
MICROBIT_USE_AFTER_FREE = 32,
MICROBIT_HEAP_ERROR = 30
};
#endif

View file

@ -15,11 +15,9 @@ static inline bool isReadOnlyInline(RefCounted *t)
return true; // object in flash
// Do some sanity checking while we're here
if (refCount == 1)
uBit.panic(MICROBIT_USE_AFTER_FREE); // object should have been deleted
if ((refCount & 1) == 0)
uBit.panic(MICROBIT_REF_COUNT_CORRUPTION); // refCount doesn't look right
if (refCount == 1 || // object should have been deleted
(refCount & 1) == 0) // refCount doesn't look right
uBit.panic(MICROBIT_HEAP_ERROR);
// Not read only
return false;