In Zlib algorithm we have decoding function. This function called inflate. At the end of the function we need to copy bytes to output. Example: (full code)
if (copy > left) copy = left;
left -= copy;
state->length -= copy;
do {
*put++ = *from++;
} while (--copy);
if (state->length == 0) state->mode = LEN;
break;
case LIT:
if (left == 0) goto inf_leave;
In this example we have do while loop with copying bytes by incrementing pointers. So we have "copy" iterations. I have question: why we cannot use just memcpy(put, from, copy) (and increment pointers after that) instead loop? Why we will have wrong decoding results in some case (when we encoding by 8kb blocks) ?
About wrong results: in result of decoding we can have unitialized bytes (little bit) . As if memcpy copy some bytes from non initialized memory.