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

Functions

EXPORT errno_t strnset_s (char *restrict dest, rsize_t dmax, int value, rsize_t n)
 Sets maximal n characters of dest to a character value, but not the final NULL character. More...
 

Function Documentation

◆ strnset_s()

EXPORT errno_t strnset_s ( char *restrict  dest,
rsize_t  dmax,
int  value,
rsize_t  n 
)

Sets maximal n characters of dest to a character value, but not the final NULL character.

With SAFECLIB_STR_NULL_SLACK defined all elements following the terminating null character (if any) written in the array of dmax characters pointed to by dest are nulled.

Remarks
EXTENSION TO
  • ISO/IEC TR 24731, Programming languages, environments and system software interfaces, Extensions to the C Library, Part I: Bounds-checking interfaces
  • Implemented in the Windows secure API as _strnset_s()
Parameters
[out]deststring that will be set.
[in]dmaxrestricted maximum length of dest
[in]valuecharacter value to write
[in]nnumber of characters to be written
Precondition
dest shall not be a null pointer, and shall be null-terminated.
dmax shall not be greater than RSIZE_MAX_STR.
dmax shall not equal zero.
n shall not be greater than dmax
value shall not be greater than 255
Return values
EOKwhen successful
ESNULLPwhen dest is NULL pointer
ESZEROLwhen dmax = 0
ESLEMAXwhen dmax > RSIZE_MAX_STR or value > 255
ESNOSPCwhen n > dmax
See also
strzero_s(), strset_s(), wcsnset_s(), strispassword_s()