Addressing comments
This commit is contained in:
parent
3cacc0a30b
commit
ae6d0e64ae
@ -2302,7 +2302,7 @@ static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
|
||||
}
|
||||
assert(repIdx >= -3);
|
||||
outSeqs[i].offset = repIdx >= 0 ? outSeqs[repIdx].offset : repStartValue[-repIdx - 1];
|
||||
if (outSeqs[i].offset == 4) {
|
||||
if (outSeqs[i].rep == 4) {
|
||||
--outSeqs[i].offset;
|
||||
}
|
||||
} else {
|
||||
@ -2319,9 +2319,6 @@ static void ZSTD_copyBlockSequences(ZSTD_CCtx* zc)
|
||||
size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
||||
size_t outSeqsSize, const void* src, size_t srcSize)
|
||||
{
|
||||
const size_t dstCapacity = ZSTD_compressBound(srcSize * sizeof(void*));
|
||||
void* dst = ZSTD_malloc(dstCapacity, ZSTD_defaultCMem);
|
||||
|
||||
SeqCollector seqCollector;
|
||||
seqCollector.collectSequences = 1;
|
||||
seqCollector.seqStart = outSeqs;
|
||||
@ -2329,8 +2326,8 @@ size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
||||
seqCollector.maxSequences = outSeqsSize;
|
||||
zc->seqCollector = seqCollector;
|
||||
|
||||
ZSTD_compress2(zc, dst, dstCapacity, src, srcSize);
|
||||
ZSTD_free(dst, ZSTD_defaultCMem);
|
||||
/* We never write to dst when collecing sequences so setting dst = src is harmless */
|
||||
ZSTD_compress2(zc, (void*)src, srcSize, src, srcSize);
|
||||
return zc->seqCollector.seqIndex;
|
||||
}
|
||||
|
||||
|
20
lib/zstd.h
20
lib/zstd.h
@ -1078,11 +1078,21 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict);
|
||||
typedef struct ZSTD_CCtx_params_s ZSTD_CCtx_params;
|
||||
|
||||
typedef struct {
|
||||
unsigned int matchPos; /* match pos in dst */
|
||||
unsigned int offset; /* offset taking into account rep (different from seqdef) */
|
||||
unsigned int litLength; /* literal length */
|
||||
unsigned int matchLength; /* match length */
|
||||
unsigned int rep; /* 0 when seq not rep and seqDef.offset otherwise */
|
||||
unsigned int matchPos; /* Match pos in dst */
|
||||
/* If seqDef.offset > 3, then this is seqDef.offset - 3
|
||||
* If seqDef.offset < 3, then this is the corresponding repeat offset
|
||||
* But if seqDef.offset < 3 and litLength == 0, this is the
|
||||
* repeat offset before the corresponding repeat offset
|
||||
* And if seqDef.offset == 3 and litLength == 0, this is the
|
||||
* most recent repeat offset - 1
|
||||
*/
|
||||
unsigned int offset;
|
||||
unsigned int litLength; /* Literal length */
|
||||
unsigned int matchLength; /* Match length */
|
||||
/* 0 when seq not rep and seqDef.offset otherwise
|
||||
* when litLength == 0 this will be <= 4, otherwise <= 3 like normal
|
||||
*/
|
||||
unsigned int rep;
|
||||
} ZSTD_Sequence;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
Reference in New Issue
Block a user