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