Permalink
Browse files

Fixed memory leak with derived classes

  • Loading branch information...
clintbellanger committed Jul 14, 2011
1 parent c5997e6 commit 05b5a9ceb3d2b1c03d94e0a745504d7090e60de5
Showing with 12 additions and 2 deletions.
  1. +1 −1 src/Entity.h
  2. +2 −0 src/GameState.cpp
  3. +1 −0 src/GameState.h
  4. +3 −0 src/GameStateLoad.cpp
  5. +1 −1 src/GameStateTitle.cpp
  6. +3 −0 src/Menu.cpp
  7. +1 −0 src/Menu.h
View
@@ -26,7 +26,7 @@ class Entity {
public:
Entity(MapIso*);
- ~Entity();
+ virtual ~Entity();
bool move();
int face(int, int);
View
@@ -21,3 +21,5 @@ void GameState::logic() {
void GameState::render() {
}
+GameState::~GameState() {
+}
View
@@ -10,6 +10,7 @@
class GameState {
public:
GameState(SDL_Surface *_screen, InputState *_inp, FontEngine *_font);
+ virtual ~GameState();
virtual void logic();
virtual void render();
View
@@ -370,4 +370,7 @@ GameStateLoad::~GameStateLoad() {
delete button_exit;
delete button_action;
delete items;
+ for (int i=0; i<GAME_SLOT_MAX; i++) {
+ SDL_FreeSurface(sprites[i]);
+ }
}
View
@@ -66,7 +66,7 @@ void GameStateTitle::render() {
button_exit->render();
// version number
- font->render("Flare Alpha v0.14", VIEW_W-2, 2, JUSTIFY_RIGHT, screen, FONT_WHITE);
+ font->render("Flare Alpha v0.14.1", VIEW_W-2, 2, JUSTIFY_RIGHT, screen, FONT_WHITE);
}
View
@@ -16,3 +16,6 @@ Menu::Menu(SDL_Surface *_screen, InputState *_inp, FontEngine *_font) {
visible = false;
}
+
+Menu::~Menu() {
+}
View
@@ -25,6 +25,7 @@ class Menu {
public:
Menu(SDL_Surface*, InputState*, FontEngine*);
+ virtual ~Menu();
bool visible;

0 comments on commit 05b5a9c

Please sign in to comment.