}
}
+/* Return length of ziplist. */
+unsigned int ziplistLen(unsigned char *zl) {
+ unsigned int len = 0;
+ if (ZIPLIST_LENGTH(zl) < ZIP_BIGLEN) {
+ len = ZIPLIST_LENGTH(zl);
+ } else {
+ unsigned char *p = zl+ZIPLIST_HEADER_SIZE;
+ while (*p != ZIP_END) {
+ p += zipRawEntryLength(p);
+ len++;
+ }
+
+ /* Re-store length if small enough */
+ if (len < ZIP_BIGLEN) ZIPLIST_LENGTH(zl) = len;
+ }
+ return len;
+}
+
void ziplistRepr(unsigned char *zl) {
unsigned char *p, encoding;
unsigned int l, lsize;
unsigned int ziplistGet(unsigned char *p, unsigned char **e, unsigned int *elen, long long *v);
unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p);
unsigned char *ziplistDeleteRange(unsigned char *zl, unsigned int index, unsigned int num);
-unsigned int ziplistCompare(unsigned char *p, unsigned char *entry, unsigned int elen);
\ No newline at end of file
+unsigned int ziplistCompare(unsigned char *p, unsigned char *entry, unsigned int elen);
+unsigned int ziplistLen(unsigned char *zl);
\ No newline at end of file