Unverified Commit c4b52fc7 authored by huangzhw's avatar huangzhw Committed by GitHub
Browse files

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: default avatarOran Agra <oran@redislabs.com>
parent e87c31de
...@@ -431,19 +431,21 @@ unsigned int zipStoreEntryEncoding(unsigned char *p, unsigned char encoding, uns ...@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment