summaryrefslogtreecommitdiff
path: root/src/string/memset_s.c
blob: 90157c9b1d69b346f4f0c677d61c901f372161c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <string.h>
#include "_safety.h"

/** fill memory **/
errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n)
{
	SIGNAL_SAFE(0);
	ASSERT_NONNULL(s);

	unsigned char *_s = (unsigned char *)s;
	rsize_t i = 0;

	while (i < n && i < smax) {
		_s[i] = (unsigned char)c;
	}

	return 0;
}

CHECK_4(errno_t, 0, memset_s, void *, rsize_t, int, rsize_t)

/***
The fn(memset) function fills the first arg(n) bytes of memory at arg(s) with
the value arg(c) (converted to an type(unsigned char)).
***/

/* UNSPECIFIED: - */
/* UNDEFINED: - */
/* IMPLEMENTATION: - */
/* LOCALE: - */

/* RETURN: the value of arg(s) */

/*
CEXT1(201112)
*/