ref: ec20ab58efe4ba3c9ac1fb194e4bea3910faca37
parent: 783adb9afe83af4f598ad19d327aa813e71276a1
author: Martin Storsjö <[email protected]>
date: Sun Jan 26 10:19:03 EST 2014
Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers
--- a/codec/decoder/plus/src/welsCodecTrace.cpp
+++ b/codec/decoder/plus/src/welsCodecTrace.cpp
@@ -59,19 +59,14 @@
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;
--- a/codec/encoder/plus/src/welsCodecTrace.cpp
+++ b/codec/encoder/plus/src/welsCodecTrace.cpp
@@ -119,19 +119,15 @@
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) {