regroup all mentions of ZSTD_REP_MOVE within zstd_compress_internal.h
This commit is contained in:
parent
a34ccad9a6
commit
de9f52e945
@ -67,7 +67,6 @@ extern "C" {
|
||||
#define ZSTD_OPT_NUM (1<<12)
|
||||
|
||||
#define ZSTD_REP_NUM 3 /* number of repcodes */
|
||||
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
||||
static UNUSED_ATTR const U32 repStartValue[ZSTD_REP_NUM] = { 1, 4, 8 };
|
||||
|
||||
#define KB *(1 <<10)
|
||||
|
@ -129,7 +129,7 @@ size_t ZSTD_buildBlockEntropyStats(seqStore_t* seqStorePtr,
|
||||
*********************************/
|
||||
|
||||
typedef struct {
|
||||
U32 off; /* Offset code (offset + ZSTD_REP_MOVE) for the match */
|
||||
U32 off; /* Offset sumtype code for the match, using ZSTD_storeSeq() format */
|
||||
U32 len; /* Raw length of match */
|
||||
} ZSTD_match_t;
|
||||
|
||||
@ -577,22 +577,21 @@ ZSTD_safecopyLiterals(BYTE* op, BYTE const* ip, BYTE const* const iend, BYTE con
|
||||
while (ip < iend) *op++ = *ip++;
|
||||
}
|
||||
|
||||
#define ZSTD_REP_MOVE (ZSTD_REP_NUM-1)
|
||||
#define STORE_REPCODE_1 STORE_REPCODE(1)
|
||||
#define STORE_REPCODE_2 STORE_REPCODE(2)
|
||||
#define STORE_REPCODE_3 STORE_REPCODE(3)
|
||||
#define STORE_REPCODE(r) (assert((r)>=1), assert((r)<=3), (r)-1)
|
||||
#define STORE_OFFSET(o) (assert((o)>0), o + ZSTD_REP_MOVE)
|
||||
#define STORED_IS_OFFSET(o) ((o) > ZSTD_REP_MOVE)
|
||||
#define STORED_IS_REPCODE(o) ((o) < ZSTD_REP_NUM)
|
||||
#define STORED_IS_REPCODE(o) ((o) <= ZSTD_REP_MOVE)
|
||||
#define STORED_OFFSET(o) (assert(STORED_IS_OFFSET(o)), (o)-ZSTD_REP_MOVE)
|
||||
#define STORED_REPCODE(o) (assert(STORED_IS_REPCODE(o)), (o)+1) /* returns ID 1,2,3 */
|
||||
#define STORED_TO_OFFBASE(o) ((o)+1)
|
||||
|
||||
/*! ZSTD_storeSeq() :
|
||||
* Store a sequence (litlen, litPtr, offCode and matchLength) into seqStore_t.
|
||||
* @offBase_minus1 : distance to match + ZSTD_REP_MOVE (values <= ZSTD_REP_MOVE are repCodes).
|
||||
* Users should not specify the encoded value directly,
|
||||
* instead use macros STORE_REPCODE_X and STORE_OFFSET().
|
||||
* @offBase_minus1 : Users should use employ macros STORE_REPCODE_X and STORE_OFFSET().
|
||||
* @matchLength : must be >= MINMATCH
|
||||
* Allowed to overread literals up to litLimit.
|
||||
*/
|
||||
|
@ -1648,9 +1648,8 @@ ZSTD_compressBlock_lazy_generic(
|
||||
}
|
||||
|
||||
/* NOTE:
|
||||
* start[-offset+ZSTD_REP_MOVE-1] is undefined behavior.
|
||||
* (-offset+ZSTD_REP_MOVE-1) is unsigned, and is added to start, which
|
||||
* overflows the pointer, which is undefined behavior.
|
||||
* Pay attention that `start[-value]` can lead to strange undefined behavior
|
||||
* notably if `value` is unsigned, resulting in a large positive `-value`.
|
||||
*/
|
||||
/* catch up */
|
||||
if (offcode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user