memmove
will never return anything other than dest
.
Returning dest
, as opposed to making memmove
void, is useful when the first argument is a computed expression, because it lets you avoid computing the same value upfront, and storing it in a variable. This lets you do in a single line
void *dest = memmove(&buf[offset] + copiedSoFar, src + offset, sizeof(buf)-offset-copiedSoFar);
what you would otherwise need to do on two lines:
void *dest = &buf[offset] + copiedSoFar;
memmove(dest, src + offset, sizeof(buf)-offset-copiedSoFar);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…