From d6bdbfe90e907535f62d5bd124318e3cd7db2753 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 21 Jan 2017 22:58:02 -0500 Subject: [PATCH] DSPAssembler: Use std::string instead of malloced char buffers in AssembleFile --- Source/Core/Core/DSP/DSPAssembler.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp index 327bf49f6c..26851e9684 100644 --- a/Source/Core/Core/DSP/DSPAssembler.cpp +++ b/Source/Core/Core/DSP/DSPAssembler.cpp @@ -929,28 +929,26 @@ bool DSPAssembler::AssembleFile(const std::string& file_path, int pass) { if (params[0].type == P_STR) { - char* tmpstr; - u32 thisCodeline = code_line; + std::string include_file_path; + const u32 this_code_line = code_line; - if (include_dir.size()) + if (include_dir.empty()) { - tmpstr = (char*)malloc(include_dir.size() + strlen(params[0].str) + 2); - sprintf(tmpstr, "%s/%s", include_dir.c_str(), params[0].str); + include_file_path = params[0].str; } else { - tmpstr = (char*)malloc(strlen(params[0].str) + 1); - strcpy(tmpstr, params[0].str); + include_file_path = include_dir + '/' + params[0].str; } - AssembleFile(tmpstr, pass); + AssembleFile(include_file_path, pass); - code_line = thisCodeline; - - free(tmpstr); + code_line = this_code_line; } else + { ShowError(ERR_EXPECTED_PARAM_STR); + } continue; }