PatchworkOS
Loading...
Searching...
No Matches
memset_s.c
Go to the documentation of this file.
2#include <errno.h>
3#include <stdint.h>
4#include <stdlib.h>
5#include <string.h>
6
8
9errno_t memset_s(void* s, rsize_t smax, int c, rsize_t n)
10{
11 unsigned char* p = (unsigned char*)s;
12
13 if (s == NULL || smax > RSIZE_MAX || n > RSIZE_MAX || n > smax)
14 {
15 if (s != NULL && smax <= RSIZE_MAX)
16 {
17 memset(s, c, smax);
18 }
19
21 return EINVAL;
22 }
23
24 while (n--)
25 {
26 *p++ = (unsigned char)c;
27 }
28
29 return 0;
30}
constraint_handler_t _constraintHandler
#define _CONSTRAINT_VIOLATION(e)
int errno_t
Definition errno_t.h:4
#define EINVAL
Invalid argument.
Definition errno.h:142
#define NULL
Pointer error value.
Definition NULL.h:23
errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n)
Definition memset_s.c:9
__SIZE_TYPE__ rsize_t
Definition rsize_t.h:4
_PUBLIC void * memset(void *s, int c, size_t n)
Definition memset.c:4