Hi Massimiliano,
Your neglecting constness.
Try this...
void* qmemcpy(void* dst, void const* src, register long len) { // assert(dst != NULL); // assert(src != NULL); // assert(len > 0); register char* d = dst; register char const* s = src; for(; --len >= 0; *d++ = *s++) /*no body*/; return dst; }
...and remember: the optimizer is amazing, and works hard to eliminate inefficiencies and improve performance.
Also, there are some tricks you could do that would improve the performance of the above as much as an order of magnitude by "tricky use of switch statement loop unrolling" and moving larger items at a time (with alignment constraints on certain platforms). Assuming that performance is important.
Don't undervalue the standard memcpy routine. Some compilers have a nicely optimized memcpy.
HTH, --Eljay