[libzstd] Fix decompression dictionary bugs and clean up initialization

Bugs:

* `ZSTD_DCtx_refPrefix()` didn't clear the dictionary after the first
  use. Fix and add a test case.
* `ZSTD_DCtx_reset()` always cleared the dictionary. Fix and add a test
  case.
* After calling `ZSTD_resetDStream()` you could no longer load a
  dictionary, since the stage was set to `zdss_loadHeader`. Fix and add
  a test case.

Cleanup:

* Make `ZSTD_initDStream*()` and `ZSTD_resetDStream()` wrap the new
 advanced API, and add test cases.
* Document the equivalent of these functions in the advanced API and
  document the unstable functions as deprecated.
This commit is contained in:
Nick Terrell
2019-04-10 12:59:02 -07:00
parent f86d4bd1d5
commit 50b9c41196
5 changed files with 274 additions and 29 deletions
@@ -123,6 +123,9 @@ struct ZSTD_DCtx_s
const ZSTD_DDict* ddict; /* set by ZSTD_initDStream_usingDDict(), or ZSTD_DCtx_refDDict() */
U32 dictID;
int ddictIsCold; /* if == 1 : dictionary is "new" for working context, and presumed "cold" (not in cpu cache) */
int dictUsesRemaining; /* if == 1 : dictionary should be used once.
* if == 0 : dictionary should be forgotten now.
* if < 0 : dictionary should be used indefinitely. */
/* streaming */
ZSTD_dStreamStage streamStage;