From f6583ac4b10f9e703fe1d44a1847444d34e09ab6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 6 Jun 2010 00:24:46 +0300 Subject: Fix memory leak in minimap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Thorbjørn Lindeijer --- src/gui/minimap.cpp | 4 +--- src/map.cpp | 7 ++----- src/map.h | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 53d58d2e..35844f64 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -98,15 +98,13 @@ void Minimap::setMap(Map *map) if (map) { std::string tempname = - "graphics/minimaps/"+(*map->getFilename())+".png"; + "graphics/minimaps/" + map->getFilename() + ".png"; ResourceManager *resman = ResourceManager::getInstance(); minimapName = map->getProperty("minimap"); if (minimapName.empty() && resman->exists(tempname)) - { minimapName = tempname; - } mMapImage = resman->getImage(minimapName); } diff --git a/src/map.cpp b/src/map.cpp index 7ee18450..52459415 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -580,16 +580,13 @@ const std::string Map::getName() const return getProperty("mapname"); } -const std::string *Map::getFilename() const +const std::string Map::getFilename() const { std::string fileName = getProperty("_filename"); int lastSlash = fileName.rfind("/") + 1; int lastDot = fileName.rfind("."); - std::string *sub = new std::string( - fileName.substr(lastSlash, lastDot - lastSlash)); - - return sub; + return fileName.substr(lastSlash, lastDot - lastSlash); } Position Map::checkNodeOffsets(int radius, unsigned char walkMask, diff --git a/src/map.h b/src/map.h index 0832df93..9fc32232 100644 --- a/src/map.h +++ b/src/map.h @@ -269,7 +269,7 @@ class Map : public Properties /** * Gives the map id based on filepath (ex: 009-1) */ - const std::string *getFilename() const; + const std::string getFilename() const; /** * Check the current position against surrounding blocking tiles, and -- cgit v1.2.3-70-g09d2