]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
changed randomly generated samples to randomly selected from the dictionary content
authorPaul Cruz <paulcruz74@fb.com>
Wed, 14 Jun 2017 23:42:51 +0000 (16:42 -0700)
committerPaul Cruz <paulcruz74@fb.com>
Wed, 14 Jun 2017 23:42:51 +0000 (16:42 -0700)
tests/decodecorpus.c

index 9bd6506e29f3754dd7d46c9a9de554fffcc50a11..19cf6127b3f21f348fc7881801ef413ef40a87f1 100644 (file)
@@ -1352,7 +1352,22 @@ static int generateCorpusWithDict(U32 seed, unsigned numFiles, const char* const
                 curr++;
             }
             samples = malloc(totalSize);
-            RAND_buffer(&seed, samples, totalSize);
+
+            /* reset pointer and counter */
+            curr = sampleSizes;
+            i = 0;
+
+            {
+                /* take substring from dictionary content */
+                size_t pos = 0;
+                const BYTE* endDict = dictContent + dictSize - 400;
+                while(i++ < numSamples){
+                    size_t currSize = *(curr++);
+                    BYTE* startSubstring = endDict - currSize;
+                    memcpy(samples + pos, (void*)startSubstring, currSize);
+                    pos += currSize;
+                }
+            }
         }
 
         {