/** * @Method: Memcpy * @Access: public * @Return: void * * @Param : dst - 目的起始地址 * @Param : src - 源起始地址 * @Param : len - 所要拷贝空间大小Byte * @Brief : 内存拷贝,实现了内存重叠和非重叠的拷贝 * @Date : 2015-8-20 FengKang */ void *Memcpy(void *dst, const void *src, size_t len) { if(NULL == dst || NULL == src) { return NULL; } void *ret = dst; if(dst <= src || (char *)dst >= (char *)src + len) { while(len--) { *(char *)dst = *(char *)src; dst = (char *)dst + 1; src = (char *)src + 1; } } else { src = (char *)src + len - 1; dst = (char *)dst + len - 1; while(len--) { *(char *)dst = *(char *)src; dst = (char *)dst - 1; src = (char *)src - 1; } } return ret; }
时间: 2024-11-16 21:23:06