Copy data octets from one memory buffer to another memory buffer.
lib_mem.h/lib_mem.c
void Mem_Copy ( void *pdest, const void *psrc, CPU_SIZE_T size); |
pdest
Pointer to the destination memory buffer.
psrc
Pointer to the source memory buffer.
size
Number of octets to copy.
None.
None.
Mem_Copy()
performs the data octet copy via CPU_ALIGN
-sized words and/or octets; and since CPU_ALIGN
-sized words must be accessed on word-aligned addresses, neither CPU_ALIGN
-sized words nor octets at unique addresses can ever overlap. Therefore, Mem_Copy()
should be able to successfully copy overlapping memory buffers as long as the source memory buffer is at a higher address value than the destination memory buffer.CPU_INT08U AppBuf[10]; CPU_INT08U DataBuf[20]; /* Set data buffer with value. */ Mem_Set ((void *)&DataBuf[0], (CPU_INT08U) 0x64, (CPU_SIZE_T) sizeof(DataBuf)); /* Copy data buffer to app buffer. */ Mem_Copy((void *)&AppBuf[0], (void *)&DataBuf[0], (CPU_SIZE_T) sizeof(AppBuf)); |