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,11 +8789,17 @@ 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) {
if (formattedLen <= 0) {
return MA_INVALID_OPERATION;
}
char* pFormattedMessage = NULL;
pFormattedMessage = (char*)ma_malloc(formattedLen + 1, &pLog->allocationCallbacks);
if (pFormattedMessage != NULL) {
if (pFormattedMessage == NULL) {
return MA_OUT_OF_MEMORY;
}
ma_result result;
/* We'll get errors on newer versions of Visual Studio if we try to use vsprintf(). */
......@@ -8811,12 +8817,6 @@ MA_API ma_result ma_log_postv(ma_log* pLog, ma_uint32 level, const char* pFormat
ma_free(pFormattedMessage, &pLog->allocationCallbacks);
return result;
} else {
return MA_OUT_OF_MEMORY;
}
} else {
return MA_INVALID_OPERATION;
}
}
#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