mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-26 06:18:32 +00:00
Use printf-like format in JitRegister::Register
The API is cleaner (no more magic default parameter) and more extensible like this.
This commit is contained in:
parent
beaa9905a6
commit
a957f93532
5 changed files with 19 additions and 16 deletions
|
@ -95,28 +95,30 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
|
|||
std::string StringFromFormat(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
std::string res = StringFromFormatV(format, args);
|
||||
va_end(args);
|
||||
return std::move(res);
|
||||
}
|
||||
|
||||
std::string StringFromFormatV(const char* format, va_list args)
|
||||
{
|
||||
char *buf = nullptr;
|
||||
#ifdef _WIN32
|
||||
int required = 0;
|
||||
|
||||
va_start(args, format);
|
||||
required = _vscprintf(format, args);
|
||||
int required = _vscprintf(format, args);
|
||||
buf = new char[required + 1];
|
||||
CharArrayFromFormatV(buf, required + 1, format, args);
|
||||
va_end(args);
|
||||
|
||||
std::string temp = buf;
|
||||
delete[] buf;
|
||||
#else
|
||||
va_start(args, format);
|
||||
if (vasprintf(&buf, format, args) < 0)
|
||||
ERROR_LOG(COMMON, "Unable to allocate memory for string");
|
||||
va_end(args);
|
||||
|
||||
std::string temp = buf;
|
||||
free(buf);
|
||||
#endif
|
||||
return temp;
|
||||
return std::move(temp);
|
||||
}
|
||||
|
||||
// For Debugging. Read out an u8 array.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue