summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2015-01-07 10:20:55 +0100
committerantirez <antirez@gmail.com>2015-01-07 10:21:01 +0100
commit0760c1f2f479ab012afdbe9021d85b02a2640f0b (patch)
treee0ed4020fc5b550feccc205c684404043fe26cf6
parent88b4830861f59703130d5f520e39b583ed979f09 (diff)
downloadredis-0760c1f2f479ab012afdbe9021d85b02a2640f0b.tar.gz
Use RDB_LOAD_PLAIN to load quicklists and encoded types.
Before we needed to create a string object with an embedded SDS, adn basically duplicate the SDS part into a plain zmalloc() allocation.
-rw-r--r--src/rdb.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/rdb.c b/src/rdb.c
index 47ae28a20..4c8a22826 100644
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -1041,12 +1041,8 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
server.list_compress_depth);
while (len--) {
- if ((ele = rdbLoadStringObject(rdb)) == NULL) return NULL;
- /* 'ele' contains a sds of the ziplist, but we need to extract
- * the actual ziplist for future usage. We must copy the
- * sds contents to a new buffer. */
- unsigned char *zl = (unsigned char *)sdsnative(ele->ptr);
- zfree(ele); /* free robj container since we keep the ziplist */
+ unsigned char *zl = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
+ if (zl == NULL) return NULL;
quicklistAppendZiplist(o->ptr, zl);
}
} else if (rdbtype == REDIS_RDB_TYPE_HASH_ZIPMAP ||
@@ -1055,9 +1051,9 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
rdbtype == REDIS_RDB_TYPE_ZSET_ZIPLIST ||
rdbtype == REDIS_RDB_TYPE_HASH_ZIPLIST)
{
- o = rdbLoadStringObject(rdb);
- if (o == NULL) return NULL;
- o->ptr = sdsnative(o->ptr);
+ unsigned char *encoded = rdbGenericLoadStringObject(rdb,RDB_LOAD_PLAIN);
+ if (encoded == NULL) return NULL;
+ o = createObject(REDIS_STRING,encoded); /* Obj type fixed below. */
/* Fix the object encoding, and make sure to convert the encoded
* data type into the base type if accordingly to the current