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 ...@@ -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); formattedLen = ma_vscprintf(&pLog->allocationCallbacks, pFormat, args2);
va_end(args2); va_end(args2);
if (formattedLen > 0) { if (formattedLen <= 0) {
char* pFormattedMessage = NULL; return MA_INVALID_OPERATION;
}
pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks); char* pFormattedMessage = NULL;
if (pFormattedMessage != NULL) {
ma_result result;
/* We'll get errors on newer versions of Visual Studio if we try to use vsprintf(). */ pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks);
#if _MSC_VER >= 1400 /* 1400 = Visual Studio 2005 */ if (pFormattedMessage == NULL) {
{ return MA_OUT_OF_MEMORY;
vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args); }
}
#else
{
vsprintf(pFormattedMessage, pFormat, args);
}
#endif
result = ma_log_post(pLog, level, pFormattedMessage); ma_result result;
ma_free(pFormattedMessage, &pLog->allocationCallbacks);
return result; /* We'll get errors on newer versions of Visual Studio if we try to use vsprintf(). */
} else { #if _MSC_VER >= 1400 /* 1400 = Visual Studio 2005 */
return MA_OUT_OF_MEMORY; {
} vsprintf_s(pFormattedMessage, formattedLen + 1, pFormat, args);
} else {
return MA_INVALID_OPERATION;
} }
#else
{
vsprintf(pFormattedMessage, pFormat, args);
}
#endif
result = ma_log_post(pLog, level, pFormattedMessage);
ma_free(pFormattedMessage, &pLog->allocationCallbacks);
return result;
} }
#else #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