void *Mymemcpy(void * pDest,const void *pSrc,unsigned int size)
{
assert(pDest!=NULL && pSrc!=NULL);
unsigned char *tmpD = (unsigned char*)pDest;
unsigned char *tmpS = (unsigned char*)pSrc;
int i=0;
if (tmpD<pSrc)
{
while(i<size)
{
*tmpD++ = *tmpS++;
++i;
}
}
else
{
size--;
tmpD +=size ;
tmpS +=size ;
while (size>=0)
{
*tmpD-- = *tmpS--;
--size;
}
}
return pDest;
}
要防止pdest和psrc所指的空间有重叠