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) {
|
||||
unsigned char *p, encoding;
|
||||
unsigned int prevrawlensize, prevrawlen, lensize, len;
|
||||
unsigned char *p;
|
||||
zlentry entry;
|
||||
|
||||
printf("{total bytes %d} {length %u}\n",ZIPLIST_BYTES(zl), ZIPLIST_LENGTH(zl));
|
||||
p = ziplistHead(zl);
|
||||
while(*p != ZIP_END) {
|
||||
prevrawlen = zipDecodeLength(p,&prevrawlensize);
|
||||
len = zipDecodeLength(p+prevrawlensize,&lensize);
|
||||
printf("{offset %ld, header %u, payload %u} ",p-zl,prevrawlensize+lensize,len);
|
||||
encoding = ZIP_ENCODING(p+prevrawlensize);
|
||||
p += prevrawlensize+lensize;
|
||||
if (encoding == ZIP_ENC_RAW) {
|
||||
fwrite(p,len,1,stdout);
|
||||
entry = zipEntry(p);
|
||||
printf("{offset %ld, header %u, payload %u} ",p-zl,entry.headersize,entry.len);
|
||||
p += entry.headersize;
|
||||
if (entry.encoding == ZIP_ENC_RAW) {
|
||||
fwrite(p,entry.len,1,stdout);
|
||||
} else {
|
||||
printf("%lld", zipLoadInteger(p,encoding));
|
||||
printf("%lld", zipLoadInteger(p,entry.encoding));
|
||||
}
|
||||
printf("\n");
|
||||
p += len;
|
||||
p += entry.len;
|
||||
}
|
||||
printf("{end}\n\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user