bug-gzip
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gzip use of memcpy


From: Jim Meyering
Subject: Re: gzip use of memcpy
Date: Fri, 08 Jan 2010 18:55:32 +0100

Alain Magloire wrote:
> Bonjour,

Bonjour Alain !  Bonne anneƩ !
It's been too long ;-)

> The behavior of memcpy is well defined:
>
> "Copying overlapping buffers isn't guaranteed to work; use memmove() to
> copy buffers that overlap"
>
> In our case for the SH architecture we have a version of memcpy that
> takes advantage at some specific instruction and above a certain size
> the copy will be done in reverse (side effect of the optimization).
>
> For overlapping copies, the code should be using memmove() as describe
> in POSIX.
...
> Index: inflate.c
...
>          if (w - d >= e)
>          {
> -          memcpy(slide + w, slide + d, e);
> +          memmove(slide + w, slide + d, e);

Can you give sample values of w, d and e for which this change
makes a difference?  Doesn't the preceding (w - d >= e) guard
ensure that the source and destination buffers never overlap?

> Index: deflate.c
...
> -        memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
> +        memmove((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);

The source and destination buffers do not overlap.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]