summaryrefslogtreecommitdiff
path: root/src/zipmap.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-02-28 09:56:48 +0100
committerantirez <antirez@gmail.com>2011-02-28 09:56:48 +0100
commit2cc993655f2c7da5f893e6f628f6c34f6204c3d3 (patch)
tree24008bc469d815740a8fa7935f57d424cd359b4e /src/zipmap.c
parent419e1cca74102440d5ce174fbbf36d81a9b8956a (diff)
downloadredis-2cc993655f2c7da5f893e6f628f6c34f6204c3d3.tar.gz
save zipmap encoded hashes as blobs. Work in progress.
Diffstat (limited to 'src/zipmap.c')
-rw-r--r--src/zipmap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/zipmap.c b/src/zipmap.c
index be780a828..9f663fda0 100644
--- a/src/zipmap.c
+++ b/src/zipmap.c
@@ -360,6 +360,18 @@ unsigned int zipmapLen(unsigned char *zm) {
return len;
}
+/* Return the raw size in bytes of a zipmap, so that we can serialize
+ * the zipmap on disk (or everywhere is needed) just writing the returned
+ * amount of bytes of the C array starting at the zipmap pointer. */
+size_t zipmapBlobLen(unsigned char *zm) {
+ unsigned char *p = zipmapRewind(zm);
+ unsigned char *old = p;
+ while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) {
+ old = p;
+ }
+ return (old-zm)+1;
+}
+
void zipmapRepr(unsigned char *p) {
unsigned int l;