Re: [PATCH RFC 1/9] lib/lz4: import upstream LZ4 sources verbatim
From: Sergey Senozhatsky
Date: Wed Sep 30 2026 - 02:08:30 EST
On (26/09/25 13:27), Michal Wilczynski wrote:
[..]
> +void LZ4_resetStream_fast(LZ4_stream_t* ctx) {
> + LZ4_prepareTable(&(ctx->internal_donotuse), 0, byU32);
> +}
[..]
> +void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const LZ4_stream_t* dictionaryStream)
> +{
> + const LZ4_stream_t_internal* dictCtx = (dictionaryStream == NULL) ? NULL :
> + &(dictionaryStream->internal_donotuse);
> +
> + DEBUGLOG(4, "LZ4_attach_dictionary (%p, %p, size %u)",
> + workingStream, dictionaryStream,
> + dictCtx != NULL ? dictCtx->dictSize : 0);
> +
> + if (dictCtx != NULL) {
> + /* If the current offset is zero, we will never look in the
> + * external dictionary context, since there is no value a table
> + * entry can take that indicate a miss. In that case, we need
> + * to bump the offset to something non-zero.
> + */
> + if (workingStream->internal_donotuse.currentOffset == 0) {
> + workingStream->internal_donotuse.currentOffset = 64 KB;
> + }
> +
> + /* Don't actually attach an empty dictionary.
> + */
> + if (dictCtx->dictSize == 0) {
> + dictCtx = NULL;
> + }
> + }
> + workingStream->internal_donotuse.dictCtx = dictCtx;
> +}
Just a side note,
there is a bunch of new helpful API added in this release. Currently,
we do some memcpy hacks to avoid re-init of lz4 C/D-dict in zram, but
once this series lands I'll be happy to send some trivial EXPORT_SYMBOL
patches so that zram (and other lz4 users) can use standard lz4 dict
API instead of hacks.