[libzstd] Fix decompression dictionary bugs and clean up initialization#1580
Merged
Conversation
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.
Cyan4973
reviewed
Apr 10, 2019
| 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. */ |
Contributor
There was a problem hiding this comment.
minor : while it works, it nonetheless feels strange to declare a member dictUsesRemaining to actually mean "use indefinitely when value is negative".
Would it be clearer to have an enum, with typically 3 values, for example use_indefinitely, use_once, do_no_longer_use ?
Contributor
|
These are very good points, I just have a minor comment regarding clarity of one internal mechanism. |
Cyan4973
approved these changes
Apr 10, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugs:
ZSTD_DCtx_refPrefix()didn't clear the dictionary after the firstuse. Fix and add a test case.
ZSTD_DCtx_reset()always cleared the dictionary. Fix and add a testcase.
ZSTD_resetDStream()you could no longer load adictionary, since the stage was set to
zdss_loadHeader. Fix and adda test case.
Cleanup:
ZSTD_initDStream*()andZSTD_resetDStream()wrap the newadvanced API, and add test cases.
document the unstable functions as deprecated.