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

/** fill memory **/

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

	ASSERT_NONNULL(s);

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

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

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

/*
STDC(1)
*/