[poincare] Tidy Integer buffer on Poincare exception

This commit is contained in:
Léa Saviot
2018-09-25 10:21:52 +02:00
committed by EmilieNumworks
parent cfcd62d2e3
commit 5b5211be24
8 changed files with 20 additions and 1 deletions

View File

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

View File

@@ -5,6 +5,8 @@ namespace Poincare {
void init();
void Tidy();
}
#endif

View File

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

View File

@@ -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();
}
}

View File

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

View File

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

View File

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

View File

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