diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-21 16:17:25 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-21 16:17:25 +0000 |
commit | e27f3c797322be87a9519a5229fab51f5856233c (patch) | |
tree | be7b7b0ff516e783a1aed1ee7a993a13313067f2 /src/resources/iteminfo.cpp | |
parent | 563e5cb7056f1e8144426a8bc1cc8eb187eb11e7 (diff) | |
download | mana-e27f3c797322be87a9519a5229fab51f5856233c.tar.gz mana-e27f3c797322be87a9519a5229fab51f5856233c.tar.bz2 mana-e27f3c797322be87a9519a5229fab51f5856233c.tar.xz mana-e27f3c797322be87a9519a5229fab51f5856233c.zip |
Plugged memory leak in equipment sound.
Diffstat (limited to 'src/resources/iteminfo.cpp')
-rw-r--r-- | src/resources/iteminfo.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
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()]; } |