Sets the first n bytes starting at dest to the specified value, but maximal dmax bytes.
- Parameters
-
[out] | dest | pointer to memory that will be set to the value |
[in] | dmax | maximum number of bytes to be written |
[in] | value | byte value to be written |
[in] | n | number of bytes to be set |
- Precondition
- dest shall not be a null pointer.
-
dmax and n shall not be greater than RSIZE_MAX_MEM.
-
value shall not be greater than 255.
-
dmax may not be smaller than n.
-
Without C11 dmax and n shall not be 0
- Note
- The behavior is undefined if the size of the character array pointed to by dest < count <= dmax; in other words, an erroneous value of dmax does not expose the impending buffer overflow.
-
C11 uses RSIZE_MAX, not RSIZE_MAX_MEM.
-
C11 returns 0 when n = ZERO.
- Returns
- If there is a runtime-constraints violation, and if dest is not a null pointer, and if dmax is not larger than RSIZE_MAX_MEM, then, before reporting the runtime-constraints violation, memset_s() copies dmax bytes to the destination.
- Return values
-
EOK | when operation is successful |
ESNULLP | when dest is NULL pointer (EINVAL with C11) |
ESZEROL | when n = ZERO (unless C11) |
ESLEMAX | when dmax/n > RSIZE_MAX_MEM or value > 255 |
ESNOSPC | when dmax < n |
- See also
- memset16_s(), memset32_s()