void memcpy(void *dest, void *src, int n) //原型
{
int i
char *Dest=(char*)dest;
char *Src=(char*)src
for(i=0;i<n;i++)
Dest[i]=Src[i];
}
对于32位,64的cpu,一次只拷贝一个字节,这显然性能最差,可尝试使用long型进行拷贝
void my_memcpy(void *dest, void *src, int n)
{
int i;
long *Dest=(long*) dest;
long *Src=(long*)src;
if(((unsigned long)Src%4==0)&&((unsigned long)Dest%4==0))
for(i=0;i<n;i++)
Dest[i]=Src[i];
else
memcpy(dest, src, n);
}