From 6ccf9f6e38782c1aa28a8dfe4f1fd31e692d6b00 Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Tue, 1 Oct 2019 23:23:38 +1000 Subject: [PATCH] snprintf for output names --- neotools/neoadpcmextract.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/neotools/neoadpcmextract.cpp b/neotools/neoadpcmextract.cpp index 3159f63..76abfaf 100644 --- a/neotools/neoadpcmextract.cpp +++ b/neotools/neoadpcmextract.cpp @@ -19,7 +19,6 @@ */ #include -#include #include #include @@ -62,6 +61,7 @@ int main(int argc, char** argv) // Search for pcm headers. std::vector smpBytes; + char namebuf[32]; int smpaCount = 0, smpbCount = 0; while (!feof(file) && !ferror(file)) { @@ -72,16 +72,14 @@ int main(int argc, char** argv) if (byte == 0x82) { printf("ADPCM-A data found at 0x%08lX\n", ftell(file)); - std::stringstream path; - path << std::hex << "smpa_" << (smpaCount++) << ".pcm"; - DecodeSample(file, path.str(), smpBytes); + snprintf(namebuf, sizeof(namebuf), "smpa_%x.pcm", smpaCount++); + DecodeSample(file, namebuf, smpBytes); } else if (byte == 0x83) { printf("ADPCM-B data found at 0x%08lX\n", ftell(file)); - std::stringstream path; - path << std::hex << "smpb_" << (smpbCount++) << ".pcm"; - DecodeSample(file, path.str(), smpBytes); + snprintf(namebuf, sizeof(namebuf), "smpb_%x.pcm", smpbCount++); + DecodeSample(file, namebuf, smpBytes); } }