MEMSET_S(3C) |
Standard C Library Functions |
MEMSET_S(3C) |
NAME
memset_s — copy a value to all bytes of a memory buffer
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#define __STDC_WANT_LIB_EXT1__ 1
#include <string.h>
errno_t
memset_s(
void *s,
rsize_t smax,
int c,
rsize_t n);
DESCRIPTION
The
memset_s() function copies the value of
c (converted to an
unsigned char) into each of the first
n bytes of the memory buffer pointed to by
s.
Unlike the
memset(3C),
memset_s() is guaranteed to never be optimized away by the compiler.
The
memset_s() function detects the following runtime-constraint violations:
-
s is a NULL pointer.
-
smax or n is greater than RSIZE_MAX.
-
n is greater than smax (buffer overflow).
If runtime-constraint violation is detected, and if
s and
smax are valid, the
memset_s() function copies the value of
c (converted to an
unsigned char) into each of the first
smax bytes of the memory buffer pointed to by
s before calling the runtime-constraint handler.
RETURN VALUES
The memset_s() function returns 0 if there was no runtime-constraint violation. Otherwise, a non-zero value is returned.
INTERFACE STABILITY
Standard
MT-LEVEL
Safe
STANDARDS
The memset_s() function conforms to ISO/IEC 9899:2011 (“ISO C11”).