cleanup: ziplist prev entry large length use sizeof(uint32_t) instead 4 (#8241)
This is just a cleanup, no bugs in the real world. Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
parent
e87c31de66
commit
c4b52fc7c9
@ -431,19 +431,21 @@ unsigned int zipStoreEntryEncoding(unsigned char *p, unsigned char encoding, uns
|
|||||||
/* Encode the length of the previous entry and write it to "p". This only
|
/* Encode the length of the previous entry and write it to "p". This only
|
||||||
* uses the larger encoding (required in __ziplistCascadeUpdate). */
|
* uses the larger encoding (required in __ziplistCascadeUpdate). */
|
||||||
int zipStorePrevEntryLengthLarge(unsigned char *p, unsigned int len) {
|
int zipStorePrevEntryLengthLarge(unsigned char *p, unsigned int len) {
|
||||||
|
uint32_t u32;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
p[0] = ZIP_BIG_PREVLEN;
|
p[0] = ZIP_BIG_PREVLEN;
|
||||||
memcpy(p+1,&len,sizeof(len));
|
u32 = len;
|
||||||
|
memcpy(p+1,&u32,sizeof(u32));
|
||||||
memrev32ifbe(p+1);
|
memrev32ifbe(p+1);
|
||||||
}
|
}
|
||||||
return 1+sizeof(len);
|
return 1 + sizeof(uint32_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encode the length of the previous entry and write it to "p". Return the
|
/* Encode the length of the previous entry and write it to "p". Return the
|
||||||
* number of bytes needed to encode this length if "p" is NULL. */
|
* number of bytes needed to encode this length if "p" is NULL. */
|
||||||
unsigned int zipStorePrevEntryLength(unsigned char *p, unsigned int len) {
|
unsigned int zipStorePrevEntryLength(unsigned char *p, unsigned int len) {
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return (len < ZIP_BIG_PREVLEN) ? 1 : sizeof(len)+1;
|
return (len < ZIP_BIG_PREVLEN) ? 1 : sizeof(uint32_t) + 1;
|
||||||
} else {
|
} else {
|
||||||
if (len < ZIP_BIG_PREVLEN) {
|
if (len < ZIP_BIG_PREVLEN) {
|
||||||
p[0] = len;
|
p[0] = len;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user