void* my_memset(void* s1, int zifu, int num) {//引用string.h
assert(s1);
void* ret = &s1;
while (num--) {
*(char*)s1 = (char)zifu;
s1 = (char*)s1 + 1;
}
return ret;
}
int my_memcmp(const void* s1,const void* s2,int num) {
assert(s1 && s2);
while (num--) {
if (*(char*)s1 > *(char*)s2) {
return 1;
}
else if (*(char*)s1 < *(char*)s2) {
return -1;
}
s1 = (char*)s1 + 1;
s2 = (char*)s2 + 1;
}
return 0;
}
void* my_memmove(void* s1,const void* s2,int num) {
void* ret = &s1;
assert(s1 && s2);
if (s1 < s2) {
while (num--) {
*(char*)s1 = *(char*)s2;
s1 = (char*)s1 + 1;
s2 = (char*)s2 + 1;
}
}
else {
while (num--) {
*((char*)s1 + num) = *((char*)s2 + num);
}
}
return ret;
}
}void* my_memcpy(void* data1,const void* data2,int num) {
assert(data1 && data2);
void* ret = data1;
while (num--) {
*(char*)data1 = *(char*)data2;
data1 = (char*)data1 + 1;
data2 = (char*)data2 + 1;
}
return ret;
}