]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
changed filed order
authorYann Collet <yann.collet.73@gmail.com>
Thu, 21 Jul 2016 13:42:23 +0000 (06:42 -0700)
committerYann Collet <yann.collet.73@gmail.com>
Fri, 22 Jul 2016 12:37:09 +0000 (14:37 +0200)
lib/decompress/zstd_decompress.c
programs/Makefile

index 4fbd1092f02aed4a76a307108a19e08069d4e9fb..16c85cf32a4b2bcb2d6ee68b21754189f0f6b174 100644 (file)
@@ -472,32 +472,29 @@ size_t ZSTD_decodeLiteralsBlock(ZSTD_DCtx* dctx,
             if (srcSize < 5) return ERROR(corruption_detected);   /* srcSize >= MIN_CBLOCK_SIZE == 3; here we need up to 5 for lhSize, + cSize (+nbSeq) */
             switch(lhlCode)
             {
-            case 1:
-                singleStream = 1;
-                /* fall through */
-            case 0: default:   /* note : default is impossible, since lhlCode into [0..3] */
+            case 0: case 1: default:   /* note : default is impossible, since lhlCode into [0..3] */
                 /* 2 - 2 - 10 - 10 */
-                {   U32 const lhc = MEM_readLE24(istart) >> 4;
+                {   U32 const lhc = MEM_readLE32(istart);
+                    singleStream = lhlCode;
                     lhSize = 3;
-                    litSize  = lhc & 0x3FF;
-                    litCSize = lhc >> 10;
+                    litSize  = (lhc >> 4) & 0x3FF;
+                    litCSize = (lhc >> 14) & 0x3FF;
                     break;
                 }
-
             case 2:
                 /* 2 - 2 - 14 - 14 */
-                {   U32 const lhc = MEM_readLE32(istart) >> 4;
+                {   U32 const lhc = MEM_readLE32(istart);
                     lhSize = 4;
-                    litSize  = lhc & 0x3FFF;
-                    litCSize = lhc >> 14;
+                    litSize  = (lhc >> 4) & 0x3FFF;
+                    litCSize = lhc >> 18;
                     break;
                 }
             case 3:
                 /* 2 - 2 - 18 - 18 */
-                {   U64 const lhc = (MEM_readLE32(istart) + (((U64)istart[4]) << 32)) >> 4;
+                {   U32 const lhc = MEM_readLE32(istart);
                     lhSize = 5;
-                    litSize  = lhc & 0x3FFFF;
-                    litCSize = lhc >> 18;
+                    litSize  = (lhc >> 4) & 0x3FFFF;
+                    litCSize = (lhc >> 22) + (istart[4] << 10);
                     break;
                 }
             }
index 7967426935d760cafb98412df6fcf6d879fc465f..75d3154dd00064c2d92aff4e7bcbe7dacaed6b73 100644 (file)
@@ -46,7 +46,7 @@ FLAGS   = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(MOREFLAGS)
 
 ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
 ZSTDCOMP_FILES := $(ZSTDDIR)/compress/zstd_compress.c $(ZSTDDIR)/compress/fse_compress.c $(ZSTDDIR)/compress/huf_compress.c
-ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/huf_decompress.c $(ZSTDDIR)/decompress/zstd_decompress.c
+ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/zstd_decompress.c $(ZSTDDIR)/decompress/huf_decompress.c
 ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
 ZBUFF_FILES := $(ZSTDDIR)/compress/zbuff_compress.c $(ZSTDDIR)/decompress/zbuff_decompress.c
 ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c