Use automatic variable with static size instead of dynamical allocation

This commit is contained in:
Don HO 2018-06-25 01:00:47 +02:00
parent a9d203a60a
commit 6326115662
1 changed files with 6 additions and 17 deletions

View File

@ -357,25 +357,14 @@ generic_string Buffer::getFileTime(fileTimeType ftt) const
FileTimeToSystemTime(&rawtime, &utcSystemTime); FileTimeToSystemTime(&rawtime, &utcSystemTime);
SystemTimeToTzSpecificLocalTime(nullptr, &utcSystemTime, &localSystemTime); SystemTimeToTzSpecificLocalTime(nullptr, &utcSystemTime, &localSystemTime);
int cbSize = GetDateFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, nullptr, 0); TCHAR bufDate[MAX_PATH];
if (cbSize != 0) GetDateFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, bufDate, MAX_PATH);
{ result += bufDate;
TCHAR* buf = new TCHAR[cbSize];
GetDateFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, buf, cbSize);
result += buf;
delete[] buf;
}
result += ' '; result += ' ';
cbSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, nullptr, 0); TCHAR bufTime[MAX_PATH];
if (cbSize != 0) GetTimeFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, bufTime, MAX_PATH);
{ result += bufTime;
TCHAR* buf = new TCHAR[cbSize];
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &localSystemTime, nullptr, buf, cbSize);
result += buf;
delete[] buf;
}
} }
} }
return result; return result;