summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-21 16:17:25 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-10-21 16:17:25 +0000
commite27f3c797322be87a9519a5229fab51f5856233c (patch)
treebe7b7b0ff516e783a1aed1ee7a993a13313067f2
parent563e5cb7056f1e8144426a8bc1cc8eb187eb11e7 (diff)
downloadmana-client-e27f3c797322be87a9519a5229fab51f5856233c.tar.gz
mana-client-e27f3c797322be87a9519a5229fab51f5856233c.tar.bz2
mana-client-e27f3c797322be87a9519a5229fab51f5856233c.tar.xz
mana-client-e27f3c797322be87a9519a5229fab51f5856233c.zip
Plugged memory leak in equipment sound.
-rw-r--r--ChangeLog2
-rw-r--r--src/resources/iteminfo.cpp14
-rw-r--r--src/resources/iteminfo.h3
3 files changed, 7 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index be91d6be..9bcf2a63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,8 @@
* src/resources/monsterdb.cpp: Plugged memory leak in database reader.
* src/resources/spritedef.cpp: Plugged memory leak in sprites.
* src/gui/quitdialog.cpp: Plugged memory leak in quit dialog.
+ * src/resources/iteminfo.cpp, src/resources/iteminfo.h: Plugged memory
+ leak in equipment sound.
2007-10-20 Guillaume Melquiond <guillaume.melquiond@gmail.com>
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 6654ccca..82c46e3c 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -100,22 +100,16 @@ void ItemInfo::setWeaponType(int type)
void
ItemInfo::addSound(EquipmentSoundEvent event, const std::string &filename)
{
- if (mSounds.find(event) == mSounds.end())
- {
- mSounds[event] = new std::vector<std::string>;
- }
-
- mSounds[event]->push_back("sfx/" + filename);
+ mSounds[event].push_back("sfx/" + filename);
}
const std::string&
ItemInfo::getSound(EquipmentSoundEvent event) const
{
- static const std::string empty = "";
- std::map<EquipmentSoundEvent, std::vector<std::string>*>::const_iterator i;
+ static const std::string empty;
+ std::map< EquipmentSoundEvent, std::vector<std::string> >::const_iterator i;
i = mSounds.find(event);
- return (i == mSounds.end()) ? empty :
- i->second->at(rand() % i->second->size());
+ return i == mSounds.end() ? empty : i->second[rand() % i->second.size()];
}
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index d6c43198..b6fc922c 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -49,7 +49,6 @@ class ItemInfo
* Constructor.
*/
ItemInfo():
- mImageName(""),
mImage(NULL),
mType(0),
mWeight(0),
@@ -138,7 +137,7 @@ class ItemInfo
std::map<int, std::string> mAnimationFiles;
/** Stores the names of sounds to be played at certain event. */
- std::map<EquipmentSoundEvent, std::vector<std::string>* > mSounds;
+ std::map< EquipmentSoundEvent, std::vector<std::string> > mSounds;
};
#endif