From c8d9e7f4c0c237ca75e0e53c0c643ef0f09f81bb Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Sat, 29 May 2010 16:25:05 +0200 Subject: [PATCH] change ziplistRepr to use the entry struct --- ziplist.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ziplist.c b/ziplist.c index 08253f37..a0412421 100644 --- a/ziplist.c +++ b/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"); } -- 2.47.2