diff --git a/gui.cpp b/gui.cpp index 733613f..e9684e6 100644 --- a/gui.cpp +++ b/gui.cpp @@ -112,6 +112,9 @@ Gui::~Gui() delete this->cur_gameInfo; delete this->timerController; + if (this->status_bar) + delete this->status_bar; + if (this->dlg) delete this->dlg; @@ -132,6 +135,7 @@ Gui::~Gui() SDL_FreeSurface(this->textbox); SDL_FreeSurface(this->selected_key); SDL_FreeSurface(this->highlighted_key); + SDL_FreeSurface(this->status_bar_bg); if (this->default_font) delete this->default_font; @@ -187,6 +191,7 @@ bool Gui::setTheme(const char *path) SDL_FreeSurface(this->textbox); SDL_FreeSurface(this->selected_key); SDL_FreeSurface(this->highlighted_key); + SDL_FreeSurface(this->status_bar_bg); if (this->default_font) delete this->default_font; diff --git a/menu.cpp b/menu.cpp index 19c9de6..973d745 100644 --- a/menu.cpp +++ b/menu.cpp @@ -366,6 +366,8 @@ void Menu::setTextColor(SDL_Color clr) Menu::~Menu() { + for (int i = 0; i < this->n_entries; i++) + free((void*)this->pp_msgs[i]); free(this->pp_msgs); free(this->p_submenus); } diff --git a/utils.cpp b/utils.cpp index b10c8fd..cf28a04 100644 --- a/utils.cpp +++ b/utils.cpp @@ -12,13 +12,14 @@ TTF_Font *read_and_alloc_font(const char *path, int pt_size) { TTF_Font *out; SDL_RWops *rw; - Uint8 *data = (Uint8*)xmalloc(1 * 1024*1024); + Uint8 *data; FILE *fp = fopen(path, "r"); if (!fp) { fprintf(stderr, "Could not open font %s\n", path); return NULL; } + data = (Uint8*)xmalloc(1 * 1024*1024); fread(data, 1, 1 * 1024 * 1024, fp); rw = SDL_RWFromMem(data, 1 * 1024 * 1024); if (!rw) diff --git a/virtual_keyboard.cpp b/virtual_keyboard.cpp index 9e5bba2..8b9b12a 100644 --- a/virtual_keyboard.cpp +++ b/virtual_keyboard.cpp @@ -92,6 +92,11 @@ VirtualKeyboard::VirtualKeyboard(Font *font) : GuiView(), ListenerManager() memset(this->buf, 0, sizeof(struct virtkey) * this->buf_len); } +VirtualKeyboard::~VirtualKeyboard() +{ + free(this->buf); +} + void VirtualKeyboard::draw(SDL_Surface *where, int x_base, int y_base, int w, int h) { int key_w = w / KEY_COLS; diff --git a/virtual_keyboard.hh b/virtual_keyboard.hh index 36c5995..42abb2d 100644 --- a/virtual_keyboard.hh +++ b/virtual_keyboard.hh @@ -40,6 +40,7 @@ class VirtualKeyboard : public GuiView, public ListenerManager { public: VirtualKeyboard(Font *font); + ~VirtualKeyboard(); /* Conversions */ const char *keycodeToString(int kc);