From 8356656575b4c07229dc0e9bd97fa2f67573de73 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Thu, 2 Jun 2011 02:20:51 +0100 Subject: GOB: Replace snprintf() usage with Common::String::format() Safer and less portability issues. --- engines/gob/resources.cpp | 5 +---- engines/gob/save/savehandler.cpp | 3 +-- engines/gob/sound/sound.cpp | 6 ++---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/engines/gob/resources.cpp b/engines/gob/resources.cpp index 92eec0ee25..d5497c25be 100644 --- a/engines/gob/resources.cpp +++ b/engines/gob/resources.cpp @@ -603,10 +603,7 @@ bool Resources::dumpResource(const Resource &resource, uint16 id, Common::String fileName = _fileBase; - char idStr[7]; - - snprintf(idStr, 7, "_%05d", id); - fileName += idStr; + fileName += Common::String::format("_%05d", id); fileName += "."; fileName += ext; diff --git a/engines/gob/save/savehandler.cpp b/engines/gob/save/savehandler.cpp index 9e46f1db6f..71de629f93 100644 --- a/engines/gob/save/savehandler.cpp +++ b/engines/gob/save/savehandler.cpp @@ -154,8 +154,7 @@ Common::String SlotFileIndexed::build(int slot) const { if ((slot < 0) || (((uint32) slot) >= _slotCount)) return Common::String(); - char buf[4]; - snprintf(buf, sizeof(buf), "%02d", slot); + Common::String buf = Common::String::format("%02d", slot); return _base + "." + _ext + buf; } diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp index 0ad17c1e33..212116f689 100644 --- a/engines/gob/sound/sound.cpp +++ b/engines/gob/sound/sound.cpp @@ -667,15 +667,13 @@ void Sound::bgPlay(const char *base, const char *ext, SoundType type, int count) _bgatmos->stopBA(); _bgatmos->queueClear(); - int length = strlen(base) + 7; - char *fileName = new char[length]; SoundDesc *sndDesc; for (int i = 1; i <= count; i++) { - snprintf(fileName, length, "%s%02d.%s", base, i, ext); + Common::String fileName = Common::String::format("%s%02d.%s", base, i, ext); sndDesc = new SoundDesc; - if (sampleLoad(sndDesc, type, fileName)) + if (sampleLoad(sndDesc, type, fileName.c_str())) _bgatmos->queueSample(*sndDesc); else delete sndDesc; -- cgit v1.2.3