diff --git a/Source/DSPTool/DSPTool.cpp b/Source/DSPTool/DSPTool.cpp index 340682a3cb..1dcd6e2f63 100644 --- a/Source/DSPTool/DSPTool.cpp +++ b/Source/DSPTool/DSPTool.cpp @@ -43,14 +43,15 @@ void DSP::Host::UpdateDebugger() { } -static void CodeToHeader(const std::vector& code, std::string filename, const char* name, - std::string& header) +static std::string CodeToHeader(const std::vector& code, const std::string& filename) { std::vector code_padded = code; + // Pad with nops to 32byte boundary while (code_padded.size() & 0x7f) code_padded.push_back(0); - header.clear(); + + std::string header; header.reserve(code_padded.size() * 4); header.append("#define NUM_UCODES 1\n\n"); std::string filename_without_extension; @@ -69,13 +70,14 @@ static void CodeToHeader(const std::vector& code, std::string filename, con header.append("\n\t},\n"); header.append("};\n"); + return header; } -static void CodesToHeader(const std::vector* codes, const std::vector* filenames, - u32 num_codes, const char* name, std::string& header) +static std::string CodesToHeader(const std::vector* codes, + const std::vector* filenames, u32 num_codes) { std::vector> codes_padded; - u32 reserveSize = 0; + std::size_t reserveSize = 0; for (u32 i = 0; i < num_codes; i++) { codes_padded.push_back(codes[i]); @@ -83,9 +85,10 @@ static void CodesToHeader(const std::vector* codes, const std::vector* codes, const std::vector files = GetAssemblerFiles(source); @@ -310,7 +313,7 @@ static bool PerformAssembly(const std::string& input_name, const std::string& ou } } - CodesToHeader(codes, &files, lines, output_header_name.c_str(), header); + const std::string header = CodesToHeader(codes, &files, lines); File::WriteStringToFile(header, output_header_name + ".h"); delete[] codes; @@ -337,8 +340,7 @@ static bool PerformAssembly(const std::string& input_name, const std::string& ou } if (!output_header_name.empty()) { - std::string header; - CodeToHeader(code, input_name, output_header_name.c_str(), header); + const std::string header = CodeToHeader(code, input_name); File::WriteStringToFile(header, output_header_name + ".h"); } }