summaryrefslogtreecommitdiff
path: root/zipmap.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-03-08 21:33:07 +0100
committerantirez <antirez@gmail.com>2010-03-08 21:33:07 +0100
commitb1befe6a8e4fbec81e721d1a5a0871f88411a1c9 (patch)
treeb58f5b0ac8f2c822310652bffd022d9478e69783 /zipmap.c
parentcbba7dd7c90f7b5b845d1dea86390572e5b4fa2c (diff)
downloadredis-b1befe6a8e4fbec81e721d1a5a0871f88411a1c9.tar.gz
Hashes saving / fixes
Diffstat (limited to 'zipmap.c')
-rw-r--r--zipmap.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/zipmap.c b/zipmap.c
index 5729c18f7..5f024dfa6 100644
--- a/zipmap.c
+++ b/zipmap.c
@@ -363,6 +363,15 @@ int zipmapExists(unsigned char *zm, unsigned char *key, unsigned int klen) {
return zipmapLookupRaw(zm,key,klen,NULL,NULL,NULL) != NULL;
}
+/* Return the number of entries inside a zipmap */
+unsigned int zipmapLen(unsigned char *zm) {
+ unsigned char *p = zipmapRewind(zm);
+ unsigned int len = 0;
+
+ while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) len++;
+ return len;
+}
+
void zipmapRepr(unsigned char *p) {
unsigned int l;