I am trying to move memory with possible overlap, using negative or positive increments for the *src and *dst, and without using a large temporary buffer.
I am trying to come up with an efficient replacement for the memmove()
function, something along the lines of:
smart_memmove(char *dst, const char *src, size_t num, int dst_inc, int src_inc);
dst and src may overlap, and dst_inc and src_inc may be any positive or negative integer (negative increments denote moving backwards in memory with the starting pointer at the top). I'd like to avoid using a large temporary buffer even if it means a reduction in execution speed.
An example of this would be to copy 10 bytes starting from memory location 0 incrementing at every other byte, to memory location 17 counting backwards by 1:
smart_memmove(17, 0, 10, -1, 2);
Another example would be to, say, reverse 10 series of bytes in memory locations 6, 9, 12, 15, 18, 21, 24, 27, 30, 33 by calling smart_memmove with the following parameters:
smart_memmove(6, 33, 10, 3, -3); /* or... smart_memmove(33, 6, 10, -3, 3); */