1 MEMSET_S(3C)             Standard C Library Functions             MEMSET_S(3C)
   2 
   3 NAME
   4      memset_s - copy a value to all bytes of a memory buffer
   5 
   6 LIBRARY
   7      Standard C Library (libc, -lc)
   8 
   9 SYNOPSIS
  10      #define __STDC_WANT_LIB_EXT1__ 1
  11 
  12      #include <string.h>
  13 
  14      errno_t
  15      memset_s(void *s, rsize_t smax, int c, rsize_t n);
  16 
  17 DESCRIPTION
  18      The memset_s() function copies the value of c (converted to an unsigned
  19      char) into each of the first n bytes of the memory buffer pointed to by
  20      s.
  21 
  22      Unlike the memset(3C), memset_s() is guaranteed to never be optimized
  23      away by the compiler.
  24 
  25      The memset_s() function detects the following runtime-constraint
  26      violations:
  27 
  28      1.   s is a NULL pointer.
  29 
  30      2.   smax or n is greater than RSIZE_MAX.
  31 
  32      3.   n is greater than smax (buffer overflow).
  33 
  34      If runtime-constraint violation is detected, and if s and smax are valid,
  35      the memset_s() function copies the value of c (converted to an unsigned
  36      char) into each of the first smax bytes of the memory buffer pointed to
  37      by s before calling the runtime-constraint handler.
  38 
  39 RETURN VALUES
  40      The memset_s() function returns 0 if there was no runtime-constraint
  41      violation.  Otherwise, a non-zero value is returned.
  42 
  43 INTERFACE STABILITY
  44      Standard
  45 
  46 MT-LEVEL
  47      Safe
  48 
  49 SEE ALSO
  50      memset(3C), set_constraint_handler_s(3C)
  51 
  52 STANDARDS
  53      The memset_s() function conforms to ISO/IEC 9899:2011 (``ISO C11'').
  54 
  55 illumos                         August 12, 2017                        illumos