Merge pull request #239 from mstorsjo/remove-unnecessary-calls
Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers
This commit is contained in:
commit
e17e664e1a
@ -59,19 +59,14 @@ int32_t CWelsTraceBase::SetTraceLevel (int iLevel) {
|
||||
|
||||
int32_t CWelsTraceBase::Trace (const int kLevel, const str_t* kpFormat, va_list pVl) {
|
||||
if (kLevel & m_iLevel) {
|
||||
str_t chWStrFormat[MAX_LOG_SIZE] = {0};
|
||||
str_t chBuf[MAX_LOG_SIZE] = {0};
|
||||
str_t chResult[MAX_LOG_SIZE] = {0};
|
||||
const int32_t kLen = WelsStrnlen ((const str_t*)"[DECODER]: ", MAX_LOG_SIZE);
|
||||
|
||||
WelsStrncpy (chWStrFormat, MAX_LOG_SIZE, (const str_t*)kpFormat, WelsStrnlen ((const str_t*)kpFormat, MAX_LOG_SIZE));
|
||||
|
||||
WelsStrncpy (chBuf, MAX_LOG_SIZE, (const str_t*)"[DECODER]: ", kLen);
|
||||
|
||||
WelsVsnprintf ((chBuf + kLen), MAX_LOG_SIZE - kLen, (const str_t*)kpFormat, pVl);
|
||||
WelsStrncpy (chResult, MAX_LOG_SIZE, (const str_t*)chBuf, WelsStrnlen ((const str_t*)chBuf, MAX_LOG_SIZE));
|
||||
|
||||
WriteString (kLevel, chResult);
|
||||
WriteString (kLevel, chBuf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -119,19 +119,15 @@ void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const str_
|
||||
return;
|
||||
}
|
||||
|
||||
str_t WStr_Format[MAX_LOG_SIZE] = {0};
|
||||
str_t pBuf[MAX_LOG_SIZE] = {0};
|
||||
str_t cResult[MAX_LOG_SIZE] = {0};
|
||||
const int32_t len = STRNLEN ("[ENCODER]: ", MAX_LOG_SIZE); // confirmed_safe_unsafe_usage
|
||||
|
||||
STRNCPY (WStr_Format, MAX_LOG_SIZE, Str_Format, STRNLEN (Str_Format, MAX_LOG_SIZE)); // confirmed_safe_unsafe_usage
|
||||
|
||||
STRNCPY (pBuf, MAX_LOG_SIZE, "[ENCODER]: ", len); // confirmed_safe_unsafe_usage
|
||||
WelsVsnprintf (pBuf + len, MAX_LOG_SIZE - len, WStr_Format, vl); // confirmed_safe_unsafe_usage
|
||||
STRNCPY (cResult, MAX_LOG_SIZE, pBuf, STRNLEN (pBuf, MAX_LOG_SIZE)); // confirmed_safe_unsafe_usage
|
||||
WelsVsnprintf (pBuf + len, MAX_LOG_SIZE - len, Str_Format, vl); // confirmed_safe_unsafe_usage
|
||||
|
||||
// g_WelsCodecTrace.TraceString(iLevel, cResult);
|
||||
welsCodecTrace::TraceString (iLevel, cResult);
|
||||
// g_WelsCodecTrace.TraceString(iLevel, pBuf);
|
||||
welsCodecTrace::TraceString (iLevel, pBuf);
|
||||
}
|
||||
|
||||
void welsCodecTrace::SetTraceLevel (const int32_t iLevel) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user