From 696826daf93f6870a71b88ebf355e1560b9e6c18 Mon Sep 17 00:00:00 2001 From: "Paul R. Eggert" Date: Mon, 19 Jul 2010 10:22:10 -0700 Subject: [PATCH] gzip: don't assume C99, and don't assume overlapping memcpy should work * tailor.h (NOMEMCPY): Remove. memcpy is entitled to not work on overlapping blocks. * inflate.c (inflate_codes): Don't put decl after statement. Omit NOMEMCPY. --- inflate.c | 7 +++---- tailor.h | 4 ---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/inflate.c b/inflate.c index 5f2f303..012bcb9 100644 --- a/inflate.c +++ b/inflate.c @@ -588,16 +588,15 @@ int bl, bd; /* number of bits decoded by tl[] and td[] */ /* do the copy */ do { n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e); -#if !defined(NOMEMCPY) && !defined(DEBUG) - unsigned int delta = w > d ? w - d : d - w; - if (delta >= e) +#ifndef DEBUG + if (e <= (d < w ? w - d : d - w)) { memcpy(slide + w, slide + d, e); w += e; d += e; } else /* do it slow to avoid memcpy() overlap */ -#endif /* !NOMEMCPY */ +#endif do { slide[w++] = slide[d++]; Tracevv((stderr, "%c", slide[w-1])); diff --git a/tailor.h b/tailor.h index 4fe0da0..cc150ef 100644 --- a/tailor.h +++ b/tailor.h @@ -227,10 +227,6 @@ # endif #endif -#if defined(pyr) && !defined(NOMEMCPY) /* Pyramid */ -# define NOMEMCPY /* problem with overlapping copies */ -#endif - #ifdef TOPS20 # define OS_CODE 0x0a #endif -- 2.47.2