DSPAssembler: Use std::string instead of malloced char buffers in AssembleFile

This commit is contained in:
Lioncash 2017-01-21 22:58:02 -05:00
parent cbe1ec51df
commit d6bdbfe90e

View File

@ -929,28 +929,26 @@ bool DSPAssembler::AssembleFile(const std::string& file_path, int pass)
{ {
if (params[0].type == P_STR) if (params[0].type == P_STR)
{ {
char* tmpstr; std::string include_file_path;
u32 thisCodeline = code_line; 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); include_file_path = params[0].str;
sprintf(tmpstr, "%s/%s", include_dir.c_str(), params[0].str);
} }
else else
{ {
tmpstr = (char*)malloc(strlen(params[0].str) + 1); include_file_path = include_dir + '/' + params[0].str;
strcpy(tmpstr, params[0].str);
} }
AssembleFile(tmpstr, pass); AssembleFile(include_file_path, pass);
code_line = thisCodeline; code_line = this_code_line;
free(tmpstr);
} }
else else
{
ShowError(ERR_EXPECTED_PARAM_STR); ShowError(ERR_EXPECTED_PARAM_STR);
}
continue; continue;
} }