RE: memmove broken
From: Paul Mackerras <hidden>
Date: 2003-07-04 09:37:46
Joakim Tjernlund writes:
I just realized that there is something strange going on in zlib.
zlib_inflate_fast() does a standard byte copy:
do{
*q++ = *r++;
while(--c); /* c >= 3 */
q is always greater than r and this works. This is something else than a
regular mem copy. I havn't figured out yet what is happening here but I don't
think there is a problem with backwards_memcpy()Ah. Yes. This is actually quite clever. If you have for example 256 zero bytes to compress, zlib will output a single literal zero byte and then a block reference of length 255 and offset -1, saying that the block from 1..255 is the same as the block from 0..254. So the fact that it copies forwards byte by byte is essential. So you couldn't use memcpy() either since it copies in larger chunks than 1 byte. Paul. ** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/