summaryrefslogtreecommitdiff
path: root/src/string/memset.c
blob: 0cda3b903e55b28431584b7ec3da45a57e6bd795 (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
#include <string.h>
#include "_safety.h"

/** fill memory **/

void * memset(void *s, int c, size_t n)
{
	unsigned char *p = (unsigned char *)s;
	size_t i = 0;

	SIGNAL_SAFE(0);
	ASSERT_NONNULL(s);

	for (i = 0; i < n; i++) {
		p[i] = (unsigned char)c;
	}

	/*
	RETURN_ALWAYS(ARGUMENT(s));
	*/
	return s;
}

CHECK_3(void *, 0, memset, void *, int, size_t)

/***
fills the first ARGUMENT(n) bytes of memory at ARGUMENT(s) with
the value ARGUMENT(c) (converted to an TYPE(unsigned char)).
***/

/*
STDC(1)
*/