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:

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 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

SEE ALSO


memset(3C), set_constraint_handler_s(3C)

STANDARDS


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

illumos August 12, 2017 illumos

tribblix@gmail.com :: GitHub :: Privacy