PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

ClassEMemory::Copy

ChezDoodles · 21 Apr 2006, 19:49 UTC
Is ClassEMemory::Copy equivalent to memcpy or memmove?

For overlapped memory blocks, memcpy is undefined, but memmove is guaranteed to work even if the blocks are partially overlapped.

Example:
// Insert a position in an array...
memcpy( &a[i], &a[i+1], sizeof(a[0])*j));
...might not work

however...
memmove( &a[i], &a[i+1], sizeof(a[0])*j));
...is guaranteed to work.
ClassEMemory::Copy is the same as memcpy from libc.

It is possible that it doesn't work properly when copying with overlapped memory blocks and the destination pointer points to a higher memory address than the source pointer.
I've just expanded the memory copy function with overlap checking. In most cases it takes the regular procedure, except when the area overlaps and the destination pointer is bigger than the source pointer. You can expect this in the Edge SDK 2.60.