Securely set memory to a given value
#include <string.h> errno_t memset_s( void *s, rsize_t smax, int c, size_t n );
- A pointer to the memory that you want to set. This must not be NULL.
- The maximum size of the block of memory.
- The value that you want to store in each byte.
- The number of bytes to set. This value must not be greater than the value of smax.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The memset_s() function is a secure version of memset():
- If the arguments are all valid, memset_s() copies the value of c (converted to an unsigned char) into each of the first n characters of the object pointed to by s.
- If there's a runtime-constraint violation, then if s isn't NULL, memset_s() stores the value of c (converted to an unsigned char) into each of the first smax characters of the object pointed to by s.
- Unlike memset(), any call to memset_s() assumes that the memory indicated by s may be accessible in the future and thus must contain the values indicated by c.
- The s argument is NULL, or n is greater than smax.