24 lines
463 B
C
24 lines
463 B
C
|
|
#include "memory.h"
|
||
|
|
|
||
|
|
void memcpy(const void* src, void* dst, size_t sz) {
|
||
|
|
for (size_t i = 0; i < sz; i++) {
|
||
|
|
((uint8_t*)dst)[i] = ((uint8_t*)src)[i];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
int strcmp(const char* s1, const char* s2) {
|
||
|
|
while (*s1 && (*s1 == *s2)) {
|
||
|
|
s1++;
|
||
|
|
s2++;
|
||
|
|
}
|
||
|
|
return *(const uint8_t*)s1 - *(const uint8_t*)s2;
|
||
|
|
}
|
||
|
|
|
||
|
|
int strlen(const char* str) {
|
||
|
|
int len = 0;
|
||
|
|
while(*str != 0) {
|
||
|
|
str++;
|
||
|
|
len++;
|
||
|
|
}
|
||
|
|
return len;
|
||
|
|
}
|