diff --git a/ScreenUi.cpp b/ScreenUi.cpp index fad4e79..977760a 100644 --- a/ScreenUi.cpp +++ b/ScreenUi.cpp @@ -20,15 +20,18 @@ */ #include -#include -#include #include +#include #include +#include #ifdef SCREENUI_DEBUG #include #endif +void* operator new(size_t size) { return malloc(size); } +void operator delete(void* ptr) { free(ptr); } + // TODO: Change to PROGMEM uint8_t charCheckmark[] = {0, // B00000 0, // B00000 @@ -155,10 +158,8 @@ void Container::repaint() { void Container::add(Component *component, int8_t x, int8_t y) { if (!components_ || componentsLength_ <= componentCount_) { - uint8_t newComponentsLength = (componentsLength_ * 2) + 1; - Component** newComponents = (Component**) realloc(newComponentsLength * sizeof(Component*)); - components_ = newComponents; - componentsLength_ = newComponentsLength; + componentsLength_ = (componentsLength_ * 2) + 1; + components_ = (Component**) realloc(components_, componentsLength_ * sizeof(Component*)); } components_[componentCount_++] = component; if (firstUpdateCompleted_) {