mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 11:29:24 +01:00
Fix some memory leaks
This commit is contained in:
parent
17e7d64804
commit
b7c9a8c4df
5
gui.cpp
5
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;
|
||||
|
2
menu.cpp
2
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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -40,6 +40,7 @@ class VirtualKeyboard : public GuiView, public ListenerManager
|
||||
{
|
||||
public:
|
||||
VirtualKeyboard(Font *font);
|
||||
~VirtualKeyboard();
|
||||
|
||||
/* Conversions */
|
||||
const char *keycodeToString(int kc);
|
||||
|
Loading…
Reference in New Issue
Block a user