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.
This commit is contained in:
parent
9840f11784
commit
fa93c88fa2
@ -234,6 +234,11 @@ int32_t WelsStrftime (str_t* pBuffer, int32_t iSize, const str_t* kpFormat, cons
|
|||||||
#endif
|
#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) {
|
int32_t WelsFwrite (const void_t* kpBuffer, int32_t iSize, int32_t iCount, WelsFileHandle* pFp) {
|
||||||
return fwrite (kpBuffer, iSize, iCount, pFp);
|
return fwrite (kpBuffer, iSize, iCount, pFp);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ typedef struct timeb SWelsTime;
|
|||||||
|
|
||||||
int32_t WelsSnprintf (str_t* buffer, int32_t sizeOfBuffer, const str_t* format, ...);
|
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* 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);
|
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);
|
WelsFileHandle* WelsFopen (const str_t* filename, const str_t* mode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user