mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
change ziplistRepr to use the entry struct
This commit is contained in:
parent
d593c48869
commit
c8d9e7f4c0
20
ziplist.c
20
ziplist.c
@ -496,24 +496,22 @@ unsigned int ziplistSize(unsigned char *zl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ziplistRepr(unsigned char *zl) {
|
void ziplistRepr(unsigned char *zl) {
|
||||||
unsigned char *p, encoding;
|
unsigned char *p;
|
||||||
unsigned int prevrawlensize, prevrawlen, lensize, len;
|
zlentry entry;
|
||||||
|
|
||||||
printf("{total bytes %d} {length %u}\n",ZIPLIST_BYTES(zl), ZIPLIST_LENGTH(zl));
|
printf("{total bytes %d} {length %u}\n",ZIPLIST_BYTES(zl), ZIPLIST_LENGTH(zl));
|
||||||
p = ziplistHead(zl);
|
p = ziplistHead(zl);
|
||||||
while(*p != ZIP_END) {
|
while(*p != ZIP_END) {
|
||||||
prevrawlen = zipDecodeLength(p,&prevrawlensize);
|
entry = zipEntry(p);
|
||||||
len = zipDecodeLength(p+prevrawlensize,&lensize);
|
printf("{offset %ld, header %u, payload %u} ",p-zl,entry.headersize,entry.len);
|
||||||
printf("{offset %ld, header %u, payload %u} ",p-zl,prevrawlensize+lensize,len);
|
p += entry.headersize;
|
||||||
encoding = ZIP_ENCODING(p+prevrawlensize);
|
if (entry.encoding == ZIP_ENC_RAW) {
|
||||||
p += prevrawlensize+lensize;
|
fwrite(p,entry.len,1,stdout);
|
||||||
if (encoding == ZIP_ENC_RAW) {
|
|
||||||
fwrite(p,len,1,stdout);
|
|
||||||
} else {
|
} else {
|
||||||
printf("%lld", zipLoadInteger(p,encoding));
|
printf("%lld", zipLoadInteger(p,entry.encoding));
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
p += len;
|
p += entry.len;
|
||||||
}
|
}
|
||||||
printf("{end}\n\n");
|
printf("{end}\n\n");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user