safec  3.0
Safe C Library - ISO TR24731 Bounds Checking Interface
wcsncat_s.c File Reference
#include "safe_str_lib.h"
+ Include dependency graph for wcsncat_s.c:

Functions

EXPORT errno_t wcsncat_s (wchar_t *restrict dest, rsize_t dmax, const wchar_t *restrict src, rsize_t slen)
 The wcsncat_s function appends a copy of the wide string pointed to by src (including the terminating null wide character) to the end of the wide string pointed to by dest. More...
 

Function Documentation

◆ wcsncat_s()

EXPORT errno_t wcsncat_s ( wchar_t *restrict  dest,
rsize_t  dmax,
const wchar_t *restrict  src,
rsize_t  slen 
)

The wcsncat_s function appends a copy of the wide string pointed to by src (including the terminating null wide character) to the end of the wide string pointed to by dest.

The initial character from src overwrites the null wide character at the end of dest.

All elements following the terminating null wide character (if any) written by wcsncat_s in the array of dmax wide characters pointed to by dest take unspeciļ¬ed values when wcsncat_s returns. With SAFECLIB_STR_NULL_SLACK defined the rest is cleared with 0.

Remarks
SPECIFIED IN
  • C11 standard (ISO/IEC 9899:2011): K.3.7.2.2 The wcsncat_s function (p: 618-620) http://en.cppreference.com/w/c/string/wide/wcsncat
  • ISO/IEC TR 24731, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
Parameters
[out]destpointer to wide string that will be extended by src if dmax allows. The string is null terminated. If the resulting concatenated wide string is less than dmax, the remaining slack space is nulled.
[in]dmaxrestricted maximum length of the resulting dest, including the null
[in]srcpointer to the wide string that will be concatenaed to string dest
[in]slenmaximum wide characters to append
Precondition
Neither dest nor src shall be a null pointer
dmax shall not equal zero
dmax shall not be greater than RSIZE_MAX_WSTR
dmax shall be greater than wcsnlen_s(src,m).
Copying shall not takeplace between objects that overlap
Note
C11 uses RSIZE_MAX, not RSIZE_MAX_WSTR.
Returns
If there is a runtime-constraint violation, then if dest is not a null pointer and dmax is greater than zero and not greater than RSIZE_MAX_WSTR, then wcsncat_s sets dest[0] to the 0 wide character.
Return values
EOKsuccessful operation, all the wide characters from src null terminated.
ESNULLPwhen dest/src is NULL pointer
ESZEROLwhen dmax = 0
ESLEMAXwhen dmax/slen > RSIZE_MAX_WSTR
ESUNTERMwhen dest not terminated
ESOVRLPwhen src overlaps with dest
See also
wcscat_s(), strncat_s()