Commit f56ea204 authored by Clownacy's avatar Clownacy

Restructure `ma_log_postv` to be more consistent

The `__STDC_VERSION__ >= 199901L` and the `_MSC_VER >= 1200` code
had different styles for handling errors, so I've made them match.
parent b65a1171
......@@ -8789,34 +8789,34 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat
formattedLen = ma_vscprintf(&pLog->allocationCallbacks, pFormat, args2);
va_end(args2);
if (formattedLen > 0) {
char* pFormattedMessage = NULL;
if (formattedLen <= 0) {
return MA_INVALID_OPERATION;
}
pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks);
if (pFormattedMessage != NULL) {
ma_result result;
char* pFormattedMessage = NULL;
/* We'll get errors on newer versions of Visual Studio if we try to use vsprintf(). */
#if _MSC_VER >= 1400 /* 1400 = Visual Studio 2005 */
{
vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args);
}
#else
{
vsprintf(pFormattedMessage, pFormat, args);
}
#endif
pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks);
if (pFormattedMessage == NULL) {
return MA_OUT_OF_MEMORY;
}
result = ma_log_post(pLog, level, pFormattedMessage);
ma_free(pFormattedMessage, &pLog->allocationCallbacks);
ma_result result;
return result;
} else {
return MA_OUT_OF_MEMORY;
}
} else {
return MA_INVALID_OPERATION;
/* We'll get errors on newer versions of Visual Studio if we try to use vsprintf(). */
#if _MSC_VER >= 1400 /* 1400 = Visual Studio 2005 */
{
vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args);
}
#else
{
vsprintf(pFormattedMessage, pFormat, args);
}
#endif
result = ma_log_post(pLog, level, pFormattedMessage);
ma_free(pFormattedMessage, &pLog->allocationCallbacks);
return result;
}
#else
{
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment