The change to StringFromFormat was overwriting the last character with the NULL terminating character.

Also update a deprecated function call.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6374 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Glenn Rice 2010-11-10 23:23:12 +00:00
parent 38d06e76d6
commit 072a698856
2 changed files with 5 additions and 5 deletions

View File

@ -54,13 +54,13 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
std::string StringFromFormat(const char* format, ...) std::string StringFromFormat(const char* format, ...)
{ {
int writtenCount = -1; int writtenCount = -1;
size_t newSize = strlen(format) + 4; size_t newSize = strlen(format) + 5;
char *buf = NULL; char *buf = NULL;
va_list args; va_list args;
while (writtenCount < 0) while (writtenCount < 0)
{ {
delete[] buf; delete[] buf;
buf = new char[newSize + 1]; buf = new char[newSize];
va_start(args, format); va_start(args, format);
writtenCount = vsnprintf(buf, newSize, format, args); writtenCount = vsnprintf(buf, newSize, format, args);
@ -71,7 +71,7 @@ std::string StringFromFormat(const char* format, ...)
// Instead it returns the size of the string we need. // Instead it returns the size of the string we need.
if (writtenCount > (int)newSize) if (writtenCount > (int)newSize)
{ {
newSize = writtenCount; newSize = writtenCount + 1;
writtenCount = -1; writtenCount = -1;
} }
#else #else

View File

@ -452,7 +452,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
btn->SetLabel(wxT("[ waiting ]")); btn->SetLabel(wxT("[ waiting ]"));
// apparently, this makes the "waiting" text work on Linux // apparently, this makes the "waiting" text work on Linux
wxYield(); wxTheApp->Yield();
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev); ControllerInterface::Device::Control* const ctrl = control_reference->Detect(DETECT_WAIT_TIME, dev);
@ -477,7 +477,7 @@ void GamepadPage::DetectControl( wxCommandEvent& event )
btn->SetLabel(wxT("[ waiting ]")); btn->SetLabel(wxT("[ waiting ]"));
// apparently, this makes the "waiting" text work on Linux // apparently, this makes the "waiting" text work on Linux
wxYield(); wxTheApp->Yield();
m_plugin.controls_crit.Enter(); // enter m_plugin.controls_crit.Enter(); // enter
ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev); ControllerInterface::Device::Control* const ctrl = btn->control_reference->Detect(DETECT_WAIT_TIME, dev);