Securely set memory to a given value
Synopsis:
#include <string.h>
errno_t memset_s( void *s,
rsize_t smax,
int c,
size_t n );
Arguments:
- s
- A pointer to the memory that you want to set.
This must not be NULL.
- smax
- The maximum size of the block of memory.
- c
- The value that you want to store in each byte.
- n
- The number of bytes to set.
This value must not be greater than the value of smax.
Library:
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
Description:
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.
Returns:
- EOK
- Success.
- EINVAL
- The s argument is NULL,
or n is greater than smax.
Classification:
C11
Safety: |
|
Cancellation point |
No |
Interrupt handler |
Yes |
Signal handler |
Yes |
Thread |
Yes |