ref: e17e664e1a4738ac289fa3ff231ec8916608e07a
parent: e05b607daa43304c2d862c9e00cadc1890cb6fe6
parent: ec20ab58efe4ba3c9ac1fb194e4bea3910faca37
author: Ethan Hugg <ethanhugg@gmail.com>
date: Mon Jan 27 06:50:19 EST 2014
Merge pull request #239 from mstorsjo/remove-unnecessary-calls 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) {