blob: a030c9ab9c95221353ef4221da7f8b8cb665d8f4 (
plain) (
blame)
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
|
#include <stddef.h>
void *memcpy(void *dest, const void *src, size_t count) {
const char *sp = (const char *) src;
char *dp = (char *) dest;
for (; count != 0; count--) *dp++ = *sp++;
return dest;
}
void *memset(void *dest, char val, size_t count) {
char *temp = (char *) dest;
for (; count != 0; count--) *temp++ = val;
return dest;
}
int memcmp(const void *a_ptr, const void *b_ptr, size_t size) {
const unsigned char *a = (const unsigned char *) a_ptr;
const unsigned char *b = (const unsigned char *) b_ptr;
for (size_t i = 0; i < size; i++) {
if (a[i] < b[i])
return -1;
else if (b[i] < a[i])
return 1;
}
return 0;
}
|