blob: 5a6fdc97f3c0039efec6a3e7aa0fc79b46d8a98b (
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
39
40
41
42
43
44
45
|
#include <string.h>
#include "_safety.h"
/** move memory **/
void * memmove(void *s1, const void *s2, size_t n)
{
SIGNAL_SAFE(0);
ASSERT_NONNULL(s1);
ASSERT_NONNULL(s2);
DANGEROUS_READ(s2, n);
DANGEROUS_WRITE(s1, n);
if (s1 < s2) {
for (size_t i = 0; i < n; i++) {
((char*)s1)[i] = ((char*)s2)[i];
}
} else {
while (n > 0) {
((char*)s1)[n] = ((char*)s2)[n];
n--;
}
/* last byte */
((char*)s1)[n] = ((char*)s2)[n];
}
DANGER_OVER();
/*
RETURN_ALWAYS(ARGUMENT(s1));
*/
return s1;
}
CHECK_3(void *, 0, memmove, void *, const void *, size_t)
/***
copies ARGUMENT(n) bytes of memory from the object at
ARGUMENT(s2) to the object at ARGUMENT(s1). If ARGUMENT(s1) and ARGUMENT(s2) overlap, the memory
is copied so that the ARGUMENT(n) bytes are safely written to ARGUMENT(s1).
***/
/*
STDC(1)
*/
|