ref: fa93c88fa21177dce3a33adb8c6513fc85df6476
parent: 9840f11784a559443ea8af05ffaa447e40e4a916
author: Martin Storsjö <[email protected]>
date: Tue Jan 28 07:21:34 EST 2014
Implement WelsStrcat based on WelsStrncpy This is a more convenient behaviour (truncating on overflow and always null terminating the buffer) compared to the MSVC safe strcat_s which aborts the process if the string doesn't fit into the target buffer. Also mark the source buffer as const in the function prototype.
--- a/codec/common/crt_util_safe_x.cpp
+++ b/codec/common/crt_util_safe_x.cpp
@@ -234,6 +234,11 @@
#endif
+str_t* WelsStrcat (str_t* pDest, int32_t iSizeInBytes, const str_t* kpSrc) {
+ int32_t iCurLen = strlen(pDest);
+ return WelsStrncpy(pDest + iCurLen, iSizeInBytes - iCurLen, kpSrc);
+}
+
int32_t WelsFwrite (const void_t* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
return fwrite (kpBuffer, iSize, iCount, pFp);
}
--- a/codec/common/crt_util_safe_x.h
+++ b/codec/common/crt_util_safe_x.h
@@ -77,7 +77,7 @@
int32_t WelsSnprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, ...);
str_t* WelsStrncpy (str_t* dest, int32_t sizeInBytes, const str_t* src);
-str_t* WelsStrcat (str_t* dest, int32_t sizeInBytes, str_t* src);
+str_t* WelsStrcat (str_t* dest, int32_t sizeInBytes, const str_t* src);
int32_t WelsVsnprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, va_list argptr);
WelsFileHandle* WelsFopen (const str_t* filename, const str_t* mode);