summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-06-06 00:24:46 +0300
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-06-05 23:48:45 +0200
commitf6583ac4b10f9e703fe1d44a1847444d34e09ab6 (patch)
tree9d801ddbf15a2825c64b4974e3d12b765e8c9465
parent18c1842f1e566390b4d93c94628db49c4895c881 (diff)
downloadmana-f6583ac4b10f9e703fe1d44a1847444d34e09ab6.tar.gz
mana-f6583ac4b10f9e703fe1d44a1847444d34e09ab6.tar.bz2
mana-f6583ac4b10f9e703fe1d44a1847444d34e09ab6.tar.xz
mana-f6583ac4b10f9e703fe1d44a1847444d34e09ab6.zip
Fix memory leak in minimap
Reviewed-by: Thorbjørn Lindeijer
-rw-r--r--src/gui/minimap.cpp4
-rw-r--r--src/map.cpp7
-rw-r--r--src/map.h2
3 files changed, 4 insertions, 9 deletions
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