[Scummvm-git-logs] scummvm master -> 2b3303ab739cc9e53412358985dc52df2209d6f3
mduggan
noreply at scummvm.org
Sun Dec 31 13:45:18 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2b3303ab73 ULTIMA: NUVIE: Fix small memory leak (from Coverity)
Commit: 2b3303ab739cc9e53412358985dc52df2209d6f3
https://github.com/scummvm/scummvm/commit/2b3303ab739cc9e53412358985dc52df2209d6f3
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2023-12-31T23:33:21+11:00
Commit Message:
ULTIMA: NUVIE: Fix small memory leak (from Coverity)
Changed paths:
engines/ultima/nuvie/sound/custom_sfx_manager.cpp
engines/ultima/nuvie/sound/custom_sfx_manager.h
diff --git a/engines/ultima/nuvie/sound/custom_sfx_manager.cpp b/engines/ultima/nuvie/sound/custom_sfx_manager.cpp
index ffbaf33934e..8cf39a43608 100644
--- a/engines/ultima/nuvie/sound/custom_sfx_manager.cpp
+++ b/engines/ultima/nuvie/sound/custom_sfx_manager.cpp
@@ -34,13 +34,11 @@ namespace Nuvie {
CustomSfxManager::CustomSfxManager(const Configuration *cfg, Audio::Mixer *m) : SfxManager(cfg, m) {
Common::Path cfg_filename;
- sfx_map = new Common::HashMap<uint16, uint16>();
-
config->pathFromValue("config/ultima6/sfxdir", "", custom_filepath);
build_path(custom_filepath, "sfx_map.cfg", cfg_filename);
- loadSfxMapFile(cfg_filename, sfx_map);
+ loadSfxMapFile(cfg_filename);
}
CustomSfxManager::~CustomSfxManager() {
@@ -48,19 +46,18 @@ CustomSfxManager::~CustomSfxManager() {
}
-bool CustomSfxManager::loadSfxMapFile(const Common::Path &cfg_filename, Common::HashMap<uint16, uint16> *m) {
- char seps[] = ";\r\n";
- char *token1;
- char *token2;
+bool CustomSfxManager::loadSfxMapFile(const Common::Path &cfg_filename) {
+ const char seps[] = ";\r\n";
+ const char *token1;
+ const char *token2;
NuvieIOFileRead niof;
- char *sz;
if (niof.open(cfg_filename) == false) {
DEBUG(0, LEVEL_ERROR, "Failed to open '%s'", cfg_filename.toString().c_str());
return false;
}
- sz = (char *) niof.readAll();
+ char *sz = (char *)niof.readAll();
token1 = strtok(sz, seps);
@@ -69,7 +66,7 @@ bool CustomSfxManager::loadSfxMapFile(const Common::Path &cfg_filename, Common::
int custom_wave_id = atoi(token2);
DEBUG(0, LEVEL_DEBUGGING, "%d : %d.wav\n", sfx_id, custom_wave_id);
- (*m)[sfx_id] = custom_wave_id;
+ sfx_map[sfx_id] = custom_wave_id;
token1 = strtok(nullptr, seps);
}
@@ -86,8 +83,8 @@ bool CustomSfxManager::playSfx(SfxIdType sfx_id, uint8 volume) {
bool CustomSfxManager::playSfxLooping(SfxIdType sfx_id, Audio::SoundHandle *handle, uint8 volume) {
Common::HashMap < uint16, uint16 >::iterator it;
- it = sfx_map->find((uint16)sfx_id);
- if (it != sfx_map->end()) {
+ it = sfx_map.find((uint16)sfx_id);
+ if (it != sfx_map.end()) {
playSoundSample((*it)._value, handle, volume);
return true;
}
diff --git a/engines/ultima/nuvie/sound/custom_sfx_manager.h b/engines/ultima/nuvie/sound/custom_sfx_manager.h
index 321de5b6c12..d47a44e9a18 100644
--- a/engines/ultima/nuvie/sound/custom_sfx_manager.h
+++ b/engines/ultima/nuvie/sound/custom_sfx_manager.h
@@ -43,12 +43,12 @@ public:
void playSoundSample(uint16 sample_num, Audio::SoundHandle *looping_handle, uint8 volume);
private:
- bool loadSfxMapFile(const Common::Path &cfg_filename, Common::HashMap<uint16, uint16> *m);
+ bool loadSfxMapFile(const Common::Path &cfg_filename);
private:
Common::Path custom_filepath;
- Common::HashMap<uint16, uint16> *sfx_map;
+ Common::HashMap<uint16, uint16> sfx_map;
};
} // End of namespace Nuvie
More information about the Scummvm-git-logs
mailing list