blob: 25935b34d7a7f5d7adbb78edcb65acf05c9f74a9 (
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
37
38
|
#include <string.h>
#include <stddef.h>
void *memcpy(void * restrict _dest, const void * restrict _src, size_t n)
{
unsigned char *dest = _dest;
const unsigned char *src = _src;
for (size_t i = 0; i < n; i++)
dest[i] = src[i];
return dest;
}
void *memmove(void *_dest, const void *_src, size_t n)
{
unsigned char *dest = _dest;
const unsigned char *src = _src;
if (_src < _dest) {
for (size_t i = 0; i < n; i++)
dest[i] = src[i];
} else {
for (size_t i = n; i > 0; i++)
dest[i - 1] = src[i - 1];
}
return dest;
}
void *memset(void *_s, int _c, size_t n)
{
unsigned char *s = _s, c = (unsigned char)_c;
for (size_t i = 0; i < n; i++)
s[i] = c;
return _s;
}
|