History

Pretty printed the C++ code with astyle

Ethan Hugg committed 12 years ago

Commit ff6b6691 parent 063709c225 files · +48457 −51954Browse files

Showing the changes to codec/decoder/core/src/utils.cpp (1 of 225 files). Show all

Unified · Split

codec/decoder/core/src/utils.cpp+106−135
@@ -37,7 +37,7 @@ · 36 unmodified lines
3737 *
3838 *************************************************************************************
3939 */
40−
40+
4141 #include <string.h>
4242 #include <stdlib.h>
4343 #include <math.h>
@@ -68,15 +68,14 @@ PWelsLogCallbackFunc g_pLog = NULL; · 24 unmodified lines
6868
6969
7070
71−void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...)
72−{
73− va_list pVl;
71+void_t WelsLog (void_t* pPtr, int32_t iLevel, const char* kpFmt, ...) {
72+ va_list pVl;
7473
75− PWelsDecoderContext pCtx = (PWelsDecoderContext)pPtr;
74+ PWelsDecoderContext pCtx = (PWelsDecoderContext)pPtr;
7675
77− va_start(pVl, kpFmt);
78− g_pLog(pCtx->pTraceHandle, iLevel, kpFmt, pVl);
79− va_end(pVl);
76+ va_start (pVl, kpFmt);
77+ g_pLog (pCtx->pTraceHandle, iLevel, kpFmt, pVl);
78+ va_end (pVl);
8079 }
8180
8281
@@ -84,122 +83,106 @@ void_t WelsLog(void_t *pPtr, int32_t iLevel, const char *kpFmt, ...) · 1 unmodified line
8483
8584 #if defined(_MSC_VER) && (_MSC_VER>=1500)
8685
87−int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
88−{
89− va_list pArgPtr;
90− int32_t iRc;
86+int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
87+ va_list pArgPtr;
88+ int32_t iRc;
9189
92− va_start(pArgPtr, kpFormat);
90+ va_start (pArgPtr, kpFormat);
9391
94− iRc = vsnprintf_s(pBuffer, iSizeOfBuffer, _TRUNCATE, kpFormat, pArgPtr);
92+ iRc = vsnprintf_s (pBuffer, iSizeOfBuffer, _TRUNCATE, kpFormat, pArgPtr);
9593
96− va_end(pArgPtr);
94+ va_end (pArgPtr);
9795
98− return iRc;
96+ return iRc;
9997 }
10098
101−str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
102−{
103− strncpy_s(pDest, iSizeInBytes, kpSrc, iCount);
99+str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
100+ strncpy_s (pDest, iSizeInBytes, kpSrc, iCount);
104101
105− return pDest;
102+ return pDest;
106103 }
107104
108−int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
109−{
110− return strnlen_s(kpStr, iMaxlen);
105+int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
106+ return strnlen_s (kpStr, iMaxlen);
111107 }
112108
113−int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
114−{
115− return vsprintf_s(pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
109+int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
110+ return vsprintf_s (pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
116111 }
117112
118−WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
119−{
120− WelsFileHandle* pFp = NULL;
121− if( fopen_s(&pFp, kpFilename, kpMode) != 0 ){
122− return NULL;
123− }
113+WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
114+ WelsFileHandle* pFp = NULL;
115+ if (fopen_s (&pFp, kpFilename, kpMode) != 0) {
116+ return NULL;
117+ }
124118
125− return pFp;
119+ return pFp;
126120 }
127121
128−int32_t WelsFclose(WelsFileHandle* pFp)
129−{
130− return fclose(pFp);
122+int32_t WelsFclose (WelsFileHandle* pFp) {
123+ return fclose (pFp);
131124 }
132125
133−int32_t WelsGetTimeOfDay(SWelsTime * pTp)
134−{
135− return _ftime_s(pTp);
126+int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
127+ return _ftime_s (pTp);
136128 }
137129
138−int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
139−{
140− struct tm sTimeNow;
130+int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
131+ struct tm sTimeNow;
141132
142− localtime_s(&sTimeNow, &kpTp->time);
133+ localtime_s (&sTimeNow, &kpTp->time);
143134
144− return strftime(pBuffer, iSize, kpFormat, &sTimeNow);
135+ return strftime (pBuffer, iSize, kpFormat, &sTimeNow);
145136 }
146137
147−#else
138+#else
148139
149−int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
150−{
151− va_list pArgPtr;
152− int32_t iRc;
140+int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
141+ va_list pArgPtr;
142+ int32_t iRc;
153143
154− va_start(pArgPtr, kpFormat);
144+ va_start (pArgPtr, kpFormat);
155145
156− iRc = vsprintf(pBuffer, kpFormat, pArgPtr);//confirmed_safe_unsafe_usage
146+ iRc = vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
157147
158− va_end(pArgPtr);
148+ va_end (pArgPtr);
159149
160− return iRc;
150+ return iRc;
161151 }
162152
163−str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
164−{
165− strncpy(pDest, kpSrc, iCount);//confirmed_safe_unsafe_usage
153+str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
154+ strncpy (pDest, kpSrc, iCount); //confirmed_safe_unsafe_usage
166155
167− return pDest;
156+ return pDest;
168157 }
169158
170−int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
171−{
172− return strlen(kpStr);//confirmed_safe_unsafe_usage
159+int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
160+ return strlen (kpStr); //confirmed_safe_unsafe_usage
173161 }
174162
175−int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
176−{
177− return vsprintf(pBuffer, kpFormat, pArgPtr);//confirmed_safe_unsafe_usage
163+int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
164+ return vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
178165 }
179166
180167
181−WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
182−{
183− return fopen(kpFilename, kpMode);
168+WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
169+ return fopen (kpFilename, kpMode);
184170 }
185171
186−int32_t WelsFclose(WelsFileHandle* pFp)
187−{
188− return fclose(pFp);
172+int32_t WelsFclose (WelsFileHandle* pFp) {
173+ return fclose (pFp);
189174 }
190175
191−int32_t WelsGetTimeOfDay(SWelsTime * pTp)
192−{
193− return _ftime(pTp);
176+int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
177+ return _ftime (pTp);
194178 }
195179
196−int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
197−{
198− struct tm * pTnow;
180+int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
181+ struct tm* pTnow;
199182
200− pTnow = localtime(&kpTp->time);
183+ pTnow = localtime (&kpTp->time);
201184
202− return strftime(pBuffer, iSize, kpFormat, pTnow);
185+ return strftime (pBuffer, iSize, kpFormat, pTnow);
203186 }
204187
205188
@@ -207,101 +190,89 @@ int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, con · 1 unmodified line
207190
208191 #else //GCC
209192
210−int32_t WelsSnprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, ...)
211−{
212− va_list pArgPtr;
213− int32_t iRc;
193+int32_t WelsSnprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, ...) {
194+ va_list pArgPtr;
195+ int32_t iRc;
214196
215− va_start(pArgPtr, kpFormat);
197+ va_start (pArgPtr, kpFormat);
216198
217− iRc = vsnprintf(pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
199+ iRc = vsnprintf (pBuffer, iSizeOfBuffer, kpFormat, pArgPtr);
218200
219− va_end(pArgPtr);
201+ va_end (pArgPtr);
220202
221− return iRc;
203+ return iRc;
222204 }
223205
224−str_t* WelsStrncpy(str_t * pDest, int32_t iSizeInBytes, const str_t * kpSrc, int32_t iCount)
225−{
226− return strncpy(pDest, kpSrc, iCount);//confirmed_safe_unsafe_usage
206+str_t* WelsStrncpy (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc, int32_t iCount) {
207+ return strncpy (pDest, kpSrc, iCount); //confirmed_safe_unsafe_usage
227208 }
228209
229210 #if !defined(MACOS) && !defined(UNIX) && !defined(APPLE_IOS)
230−int32_t WelsStrnlen(const str_t * kpStr, int32_t iMaxlen)
231−{
232− return strnlen(kpStr, iMaxlen);//confirmed_safe_unsafe_usage
211+int32_t WelsStrnlen (const str_t* kpStr, int32_t iMaxlen) {
212+ return strnlen (kpStr, iMaxlen); //confirmed_safe_unsafe_usage
233213 }
234214 #else
235−int32_t WelsStrnlen(const str_t *kpString, int32_t iMaxlen)
236−{
237− // In mac os, there is no strnlen in string.h, we can only use strlen instead of strnlen or
238− // implement strnlen by ourself
239−
215+int32_t WelsStrnlen (const str_t* kpString, int32_t iMaxlen) {
216+ // In mac os, there is no strnlen in string.h, we can only use strlen instead of strnlen or
217+ // implement strnlen by ourself
218+
240219 #if 1
241− return strlen(pString);//confirmed_safe_unsafe_usage
242−#else
243− const str_t *kpSrc;
244− for (kpSrc = kpString; iMaxlen-- && *kpSrc != '\0'; ++kpSrc)
245− return kpSrc - kpString;
220+ return strlen (pString); //confirmed_safe_unsafe_usage
221+#else
222+ const str_t* kpSrc;
223+ for (kpSrc = kpString; iMaxlen-- && *kpSrc != '\0'; ++kpSrc)
224+ return kpSrc - kpString;
246225 #endif
247−
226+
248227 }
249228 #endif
250229
251−int32_t WelsVsprintf(str_t * pBuffer, int32_t iSizeOfBuffer, const str_t * kpFormat, va_list pArgPtr)
252−{
253− return vsprintf(pBuffer, kpFormat, pArgPtr);//confirmed_safe_unsafe_usage
230+int32_t WelsVsprintf (str_t* pBuffer, int32_t iSizeOfBuffer, const str_t* kpFormat, va_list pArgPtr) {
231+ return vsprintf (pBuffer, kpFormat, pArgPtr); //confirmed_safe_unsafe_usage
254232 }
255233
256−WelsFileHandle* WelsFopen(const str_t * kpFilename, const str_t * kpMode)
257−{
258− return fopen(kpFilename, kpMode);
234+WelsFileHandle* WelsFopen (const str_t* kpFilename, const str_t* kpMode) {
235+ return fopen (kpFilename, kpMode);
259236 }
260237
261−int32_t WelsFclose(WelsFileHandle * pFp)
262−{
263− return fclose(pFp);
238+int32_t WelsFclose (WelsFileHandle* pFp) {
239+ return fclose (pFp);
264240 }
265241
266−int32_t WelsGetTimeOfDay(SWelsTime * pTp)
267−{
268− struct timeval sTv;
242+int32_t WelsGetTimeOfDay (SWelsTime* pTp) {
243+ struct timeval sTv;
269244
270− if( gettimeofday(&sTv, NULL) ){
271− return -1;
272− }
245+ if (gettimeofday (&sTv, NULL)) {
246+ return -1;
247+ }
273248
274− pTp->time = sTv.tv_sec;
275− pTp->millitm = (uint16_t)sTv.tv_usec/1000;
249+ pTp->time = sTv.tv_sec;
250+ pTp->millitm = (uint16_t)sTv.tv_usec / 1000;
276251
277− return 0;
252+ return 0;
278253 }
279254
280−int32_t WelsStrftime(str_t * pBuffer, int32_t iSize, const str_t * kpFormat, const SWelsTime * kpTp)
281−{
282− struct tm * pTnow;
283−
284− pTnow = localtime(&kpTp->time);
255+int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, const SWelsTime* kpTp) {
256+ struct tm* pTnow;
257+
258+ pTnow = localtime (&kpTp->time);
285259
286− return strftime(pBuffer, iSize, kpFormat, pTnow);
260+ return strftime (pBuffer, iSize, kpFormat, pTnow);
287261 }
288262
289263 #endif
290264
291265
292−int32_t WelsFwrite(const void_t * kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp)
293−{
294− return fwrite(kpBuffer, iSize, iCount, pFp);
266+int32_t WelsFwrite (const void_t* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
267+ return fwrite (kpBuffer, iSize, iCount, pFp);
295268 }
296269
297−uint16_t WelsGetMillsecond(const SWelsTime * kpTp)
298−{
299− return kpTp->millitm;
270+uint16_t WelsGetMillsecond (const SWelsTime* kpTp) {
271+ return kpTp->millitm;
300272 }
301273
302−int32_t WelsFflush(WelsFileHandle* pFp)
303−{
304− return fflush(pFp);
274+int32_t WelsFflush (WelsFileHandle* pFp) {
275+ return fflush (pFp);
305276 }
306277
307278 } // namespace WelsDec

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t