From 0a9229ff3f27aef65fab3ab3177ef8c9306c0bd2 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Thu, 2 Jun 2011 18:15:15 +0200 Subject: [PATCH] Surface: Use the destructor as intended. There is no reason to have an explicit free() method instead of just destructing the Surface object and doing cleanup in the destructor. --- src/gmenu2x.cpp | 2 +- src/surface.cpp | 6 ------ src/surface.h | 1 - src/surfacecollection.cpp | 6 +----- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index e2424ea..0dc0dac 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -327,7 +327,7 @@ GMenu2X::~GMenu2X() { void GMenu2X::quit() { fflush(NULL); sc.clear(); - s->free(); + free(s); SDL_Quit(); #ifdef TARGET_GP2X /* if (gp2x_mem!=0) { diff --git a/src/surface.cpp b/src/surface.cpp index 6be4652..5891a71 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -66,10 +66,6 @@ Surface::Surface(const string &img, const string &skin) { } Surface::~Surface() { - free(); -} - -void Surface::free() { if (freeWhenDone) { SDL_FreeSurface(raw); } @@ -83,8 +79,6 @@ SDL_PixelFormat *Surface::format() { } void Surface::load(const string &img, const string &skin) { - free(); - string skinpath; if (!skin.empty() && !img.empty() && img[0]!='/') { skinpath = "skins/"+skin+"/"+img; diff --git a/src/surface.h b/src/surface.h index 4785ccb..f998440 100644 --- a/src/surface.h +++ b/src/surface.h @@ -47,7 +47,6 @@ public: SDL_Surface *raw; - void free(); void flip(); void clearClipRect(); diff --git a/src/surfacecollection.cpp b/src/surfacecollection.cpp index 4774aa0..a1d8da5 100644 --- a/src/surfacecollection.cpp +++ b/src/surfacecollection.cpp @@ -109,11 +109,7 @@ void SurfaceCollection::del(const string &path) { } void SurfaceCollection::clear() { - while (surfaces.size()>0) { - surfaces.begin()->second->free(); - free(surfaces.begin()->second); - surfaces.erase(surfaces.begin()); - } + surfaces.clear(); } void SurfaceCollection::move(const string &from, const string &to) {