PatchworkOS
Loading...
Searching...
No Matches
memset_s.c
Go to the documentation of this file.
1
#include "
common/use_annex_k.h
"
2
#include <
errno.h
>
3
#include <
stdint.h
>
4
#include <
stdlib.h
>
5
#include <
string.h
>
6
7
#include "
common/constraint_handler.h
"
8
9
errno_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
20
_constraintHandler
(
_CONSTRAINT_VIOLATION
(
EINVAL
));
21
return
EINVAL
;
22
}
23
24
while
(n--)
25
{
26
*p++ = (
unsigned
char)c;
27
}
28
29
return
0;
30
}
_constraintHandler
constraint_handler_t _constraintHandler
Definition
constraint_handler.c:3
constraint_handler.h
_CONSTRAINT_VIOLATION
#define _CONSTRAINT_VIOLATION(e)
Definition
constraint_handler.h:10
errno.h
errno_t
int errno_t
Definition
errno_t.h:4
EINVAL
#define EINVAL
Invalid argument.
Definition
errno.h:142
NULL
#define NULL
Pointer error value.
Definition
NULL.h:23
memset_s
errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n)
Definition
memset_s.c:9
rsize_t
__SIZE_TYPE__ rsize_t
Definition
rsize_t.h:4
stdint.h
stdlib.h
string.h
memset
_PUBLIC void * memset(void *s, int c, size_t n)
Definition
memset.c:4
use_annex_k.h
src
libstd
functions
string
memset_s.c
Generated by
1.9.8