diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 000000000..47cfe3617 --- /dev/null +++ b/doc/README.md @@ -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. + + diff --git a/contrib/educational_decoder/README.md b/doc/educational_decoder/README.md similarity index 100% rename from contrib/educational_decoder/README.md rename to doc/educational_decoder/README.md diff --git a/contrib/educational_decoder/harness.c b/doc/educational_decoder/harness.c similarity index 100% rename from contrib/educational_decoder/harness.c rename to doc/educational_decoder/harness.c diff --git a/contrib/educational_decoder/zstd_decompress.c b/doc/educational_decoder/zstd_decompress.c similarity index 99% rename from contrib/educational_decoder/zstd_decompress.c rename to doc/educational_decoder/zstd_decompress.c index 856255987..ae4eaa81c 100644 --- a/contrib/educational_decoder/zstd_decompress.c +++ b/doc/educational_decoder/zstd_decompress.c @@ -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; diff --git a/contrib/educational_decoder/zstd_decompress.h b/doc/educational_decoder/zstd_decompress.h similarity index 100% rename from contrib/educational_decoder/zstd_decompress.h rename to doc/educational_decoder/zstd_decompress.h