Remove specific panic codes for ref-counting.

master
Michal Moskal 8 years ago
parent 59853855b0
commit 3900962556

@ -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

@ -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;

Loading…
Cancel
Save