]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Move educational_decoder to doc/ and add doc README
authorSean Purcell <me@seanp.xyz>
Thu, 23 Feb 2017 22:34:52 +0000 (14:34 -0800)
committerSean Purcell <me@seanp.xyz>
Thu, 23 Feb 2017 22:34:52 +0000 (14:34 -0800)
- Also make some minor bugfixes to educational decoder

doc/README.md [new file with mode: 0644]
doc/educational_decoder/README.md [moved from contrib/educational_decoder/README.md with 100% similarity]
doc/educational_decoder/harness.c [moved from contrib/educational_decoder/harness.c with 100% similarity]
doc/educational_decoder/zstd_decompress.c [moved from contrib/educational_decoder/zstd_decompress.c with 99% similarity]
doc/educational_decoder/zstd_decompress.h [moved from contrib/educational_decoder/zstd_decompress.h with 100% similarity]

diff --git a/doc/README.md b/doc/README.md
new file mode 100644 (file)
index 0000000..47cfe36
--- /dev/null
@@ -0,0 +1,20 @@
+Zstandard Documentation
+=======================
+
+This directory contains material defining the Zstandard format,
+as well as for help using the `zstd` library.
+
+__`zstd_compression_format.md`__ : This document defines the Zstandard compression format.
+Compliant decoders must adhere to this document,
+and compliant encoders must generate data that follows it.
+
+__`educational_decoder`__ : This directory contains an implementation of a Zstandard decoder,
+compliant with the Zstandard compression format.
+It can be used, for example, to better understand the format,
+or as the basis for a separate implementation a Zstandard decoder/encoder.
+
+__`zstd_manual.html`__ : Documentation on the functions found in `zstd.h`.
+See [http://zstd.net/zstd_manual.html](http://zstd.net/zstd_manual.html) for
+the manual released with the latest official `zstd` release.
+
+
similarity index 99%
rename from contrib/educational_decoder/zstd_decompress.c
rename to doc/educational_decoder/zstd_decompress.c
index 8562559877f1cc4f33d607087e337b9e4c3e9a9c..ae4eaa81c6aec9173cc13ee223ee9df85980d3bc 100644 (file)
@@ -799,7 +799,7 @@ static size_t decode_literals_simple(istream_t *const in, u8 **const literals,
     case 2:
         // "Size_Format uses 1 bit. Regenerated_Size uses 5 bits (0-31)."
         IO_rewind_bits(in, 1);
-        size = IO_read_bits(in, 2);
+        size = IO_read_bits(in, 5);
         break;
     case 1:
         // "Size_Format uses 2 bits. Regenerated_Size uses 12 bits (0-4095)."
@@ -881,7 +881,7 @@ static size_t decode_literals_compressed(frame_context_t *const ctx,
         IMPOSSIBLE();
     }
     if (regenerated_size > MAX_LITERALS_SIZE ||
-        compressed_size > regenerated_size) {
+        compressed_size >= regenerated_size) {
         CORRUPTION();
     }
 
@@ -1654,7 +1654,7 @@ static inline const u8 *IO_read_bytes(istream_t *const in, size_t len) {
 /// Returns a pointer to write `len` bytes to, and advances the internal state
 static inline u8 *IO_write_bytes(ostream_t *const out, size_t len) {
     if (len > out->len) {
-        INP_SIZE();
+        OUT_SIZE();
     }
     u8 *const ptr = out->ptr;
     out->ptr += len;