summaryrefslogtreecommitdiff
path: root/zipmap.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2010-02-27 18:13:55 +0100
committerantirez <antirez@gmail.com>2010-02-27 18:13:55 +0100
commit8ec0832157587a1d19ee0b6514c6b33d258fd51b (patch)
tree668cfe3b76c09f60898cefa2feea4aa4a597bf82 /zipmap.c
parenteb46f4bd7bf086089b0a48f1e2bed2aadb46d185 (diff)
downloadredis-8ec0832157587a1d19ee0b6514c6b33d258fd51b.tar.gz
first zipmap fix of a long sequence in the days to come ;)
Diffstat (limited to 'zipmap.c')
-rw-r--r--zipmap.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/zipmap.c b/zipmap.c
index ba5ea0e3e..d5cfa1628 100644
--- a/zipmap.c
+++ b/zipmap.c
@@ -192,14 +192,14 @@ static unsigned long zipmapRequiredLength(unsigned int klen, unsigned int vlen)
return l;
}
-/* Return the total amonut used by a key (encoded length + payload) */
+/* Return the total amount used by a key (encoded length + payload) */
static unsigned int zipmapRawKeyLength(unsigned char *p) {
unsigned int l = zipmapDecodeLength(p);
return zipmapEncodeLength(NULL,l) + l;
}
-/* Return the total amonut used by a value
+/* Return the total amount used by a value
* (encoded length + single byte free count + payload) */
static unsigned int zipmapRawValueLength(unsigned char *p) {
unsigned int l = zipmapDecodeLength(p);
@@ -303,7 +303,7 @@ void zipmapRepr(unsigned char *p) {
p += zipmapEncodeLength(NULL,l);
e = *p++;
fwrite(p,l,1,stdout);
- p += l;
+ p += l+e;
if (e) {
printf("[");
while(e--) printf(".");
@@ -320,6 +320,7 @@ int main(void) {
zm = zipmapNew();
zm = zipmapSet(zm,(unsigned char*) "hello",5, (unsigned char*) "world!",6);
zm = zipmapSet(zm,(unsigned char*) "foo",3, (unsigned char*) "bar",3);
+ zm = zipmapSet(zm,(unsigned char*) "foo",3, (unsigned char*) "!",1);
zipmapRepr(zm);
return 0;
}