MEMSET_S(3C) Standard C Library Functions MEMSET_S(3C)

memset_scopy a value to all bytes of a memory buffer

Standard C Library (libc, -lc)

#define __STDC_WANT_LIB_EXT1__ 1

#include <string.h>

errno_t
memset_s(void *s, rsize_t smax, int c, rsize_t n);

The () 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), () is guaranteed to never be optimized away by the compiler.

The () function detects the following runtime-constraint violations:

  1. s is a NULL pointer.
  2. smax or n is greater than RSIZE_MAX.
  3. n is greater than smax (buffer overflow).

If runtime-constraint violation is detected, and if s and smax are valid, the () 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.

The memset_s() function returns 0 if there was no runtime-constraint violation. Otherwise, a non-zero value is returned.

memset(3C), set_constraint_handler_s(3C)

The memset_s() function conforms to ISO/IEC 9899:2011 (“ISO C11”).

August 12, 2017 OmniOS