More memory leak fixes. Untested.

master
Jason von Nieda 13 years ago
parent d4b36291f5
commit 180ad11e7f
  1. 13
      ScreenUi.cpp

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

Loading…
Cancel
Save