mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[poincare] Tidy Integer buffer on Poincare exception
This commit is contained in:
committed by
EmilieNumworks
parent
cfcd62d2e3
commit
5b5211be24
@@ -1,6 +1,7 @@
|
||||
#include "apps_container.h"
|
||||
#include "global_preferences.h"
|
||||
#include <ion.h>
|
||||
#include <poincare/init.h>
|
||||
#include <poincare/exception_checkpoint.h>
|
||||
|
||||
extern "C" {
|
||||
@@ -181,6 +182,7 @@ void AppsContainer::run() {
|
||||
activeApp()->snapshot()->reset();
|
||||
}
|
||||
switchTo(appSnapshotAtIndex(0));
|
||||
Poincare::Tidy();
|
||||
activeApp()->displayWarning(I18n::Message::AppMemoryFull, true);
|
||||
}
|
||||
Container::run();
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace Poincare {
|
||||
|
||||
void init();
|
||||
|
||||
void Tidy();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
static Integer Overflow(bool negative) { return Integer((native_uint_t *)nullptr, k_maxNumberOfDigits+1, negative); }
|
||||
static Integer BuildInteger(native_uint_t * digits, uint16_t numberOfDigits, bool negative, bool enableOverflow = false);
|
||||
~Integer();
|
||||
static void TidyIntegerBuffer();
|
||||
|
||||
|
||||
#if POINCARE_TREE_LOG
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <poincare/init.h>
|
||||
#include <poincare/integer.h>
|
||||
#include <poincare/tree_pool.h>
|
||||
|
||||
namespace Poincare {
|
||||
@@ -9,4 +10,9 @@ void init() {
|
||||
TreePool::RegisterPool(&pool);
|
||||
}
|
||||
|
||||
void Tidy() {
|
||||
// Clean Integer
|
||||
Integer::TidyIntegerBuffer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,6 +54,10 @@ void Integer::log(std::ostream & stream) const {
|
||||
static uint16_t sbusyIntegerBuffer = 0;
|
||||
static native_uint_t sIntegerBuffer[(Integer::k_maxNumberOfDigits+1)*Integer::k_maxNumberOfIntegerSimutaneously];
|
||||
|
||||
void Integer::TidyIntegerBuffer() {
|
||||
sbusyIntegerBuffer = 0;
|
||||
}
|
||||
|
||||
native_uint_t * Integer::allocDigits(int numberOfDigits) {
|
||||
assert(numberOfDigits <= k_maxNumberOfDigits+1);
|
||||
uint16_t bitIndex = 1 << (16-1);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <quiz.h>
|
||||
#include <poincare.h>
|
||||
#include <poincare/init.h>
|
||||
#include <poincare/exception_checkpoint.h>
|
||||
#include <ion.h>
|
||||
#include <cmath>
|
||||
@@ -47,6 +48,7 @@ QUIZ_CASE(poincare_parser_memory_exhaustion) {
|
||||
a.addChildAtIndexInPlace(e, 0, a.numberOfChildren());
|
||||
}
|
||||
} else {
|
||||
Poincare::Tidy();
|
||||
memoryFailureHasBeenHandled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <quiz.h>
|
||||
#include <poincare.h>
|
||||
#include <poincare/init.h>
|
||||
#include <poincare/exception_checkpoint.h>
|
||||
#include <assert.h>
|
||||
#include "blob_node.h"
|
||||
@@ -72,6 +73,7 @@ QUIZ_CASE(tree_handle_memory_failure) {
|
||||
tree = PairByReference(tree, BlobByReference(1));
|
||||
}
|
||||
} else {
|
||||
Poincare::Tidy();
|
||||
memoryFailureHasBeenHandled = true;
|
||||
}
|
||||
quiz_assert(memoryFailureHasBeenHandled);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "quiz.h"
|
||||
#include "symbols.h"
|
||||
#include <string.h>
|
||||
#include <ion.h>
|
||||
#include <kandinsky.h>
|
||||
#include <poincare/init.h>
|
||||
#include <ion.h>
|
||||
#include <poincare/tree_pool.h>
|
||||
#include <poincare/exception_checkpoint.h>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user