From 336c82d58379205b789f3ca9cefc7c2090808fb8 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 9 Mar 2011 17:31:02 +0100 Subject: [PATCH] zipmaps are now endianess agnostic, needed for on disk serialization of zipmaps without convertions layers --- src/Makefile | 2 +- src/endian.h | 2 ++ src/zipmap.c | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 4d0f86db..acbc9b5f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -25,7 +25,7 @@ PREFIX= /usr/local INSTALL_BIN= $(PREFIX)/bin INSTALL= cp -p -OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o dscache.o pubsub.o multi.o debug.o sort.o intset.o syncio.o diskstore.o +OBJ = adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o dscache.o pubsub.o multi.o debug.o sort.o intset.o syncio.o diskstore.o endian.o BENCHOBJ = ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o CLIOBJ = anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o CHECKDUMPOBJ = redis-check-dump.o lzf_c.o lzf_d.o diff --git a/src/endian.h b/src/endian.h index 327cc570..bef82272 100644 --- a/src/endian.h +++ b/src/endian.h @@ -16,3 +16,5 @@ void memrev64(void *p); #define memrev32ifbe(p) memrev32(p) #define memrev64ifbe(p) memrev64(p) #endif + +#endif diff --git a/src/zipmap.c b/src/zipmap.c index 693db7b9..9f0fc718 100644 --- a/src/zipmap.c +++ b/src/zipmap.c @@ -80,6 +80,7 @@ #include #include #include "zmalloc.h" +#include "endian.h" #define ZIPMAP_BIGLEN 254 #define ZIPMAP_END 255 @@ -108,6 +109,7 @@ static unsigned int zipmapDecodeLength(unsigned char *p) { if (len < ZIPMAP_BIGLEN) return len; memcpy(&len,p+1,sizeof(unsigned int)); + memrev32ifbe(&len); return len; } @@ -123,6 +125,7 @@ static unsigned int zipmapEncodeLength(unsigned char *p, unsigned int len) { } else { p[0] = ZIPMAP_BIGLEN; memcpy(p+1,&len,sizeof(len)); + memrev32ifbe(p+1); return 1+sizeof(len); } } -- 2.45.2