Skip to content

Commit a12dcea

Browse files
Merge branch 'unstable' of https://github.com/EQ-Alpha/KeyDB into unstable
2 parents 9bb439d + af7257c commit a12dcea

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

src/pqsort.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include <errno.h>
4343
#include <stdlib.h>
44+
#include <stdint.h>
4445

4546
static inline char *med3 (char *, char *, char *,
4647
int (*)(const void *, const void *));
@@ -62,7 +63,7 @@ static inline void swapfunc (char *, char *, size_t, int);
6263
} while (--i > 0); \
6364
}
6465

65-
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
66+
#define SWAPINIT(a, es) swaptype = (uintptr_t)a % sizeof(long) || \
6667
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
6768

6869
static inline void

src/t_zset.cpp

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,24 +1191,26 @@ void zsetConvert(robj *zobj, int encoding) {
11911191
zs->dict = dictCreate(&zsetDictType,NULL);
11921192
zs->zsl = zslCreate();
11931193

1194-
eptr = ziplistIndex(zl,0);
1195-
serverAssertWithInfo(NULL,zobj,eptr != NULL);
1196-
sptr = ziplistNext(zl,eptr);
1197-
serverAssertWithInfo(NULL,zobj,sptr != NULL);
1198-
1199-
while (eptr != NULL) {
1200-
score = zzlGetScore(sptr);
1201-
serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
1202-
if (vstr == NULL)
1203-
ele = sdsfromlonglong(vlong);
1204-
else
1205-
ele = sdsnewlen((char*)vstr,vlen);
1194+
if (ziplistLen(zl) > 0) {
1195+
eptr = ziplistIndex(zl,0);
1196+
serverAssertWithInfo(NULL,zobj,eptr != NULL);
1197+
sptr = ziplistNext(zl,eptr);
1198+
serverAssertWithInfo(NULL,zobj,sptr != NULL);
12061199

1207-
node = zslInsert(zs->zsl,score,ele);
1208-
serverAssert(dictAdd(zs->dict,ele,&node->score) == DICT_OK);
1209-
zzlNext(zl,&eptr,&sptr);
1200+
while (eptr != NULL) {
1201+
score = zzlGetScore(sptr);
1202+
serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
1203+
if (vstr == NULL)
1204+
ele = sdsfromlonglong(vlong);
1205+
else
1206+
ele = sdsnewlen((char*)vstr,vlen);
1207+
1208+
node = zslInsert(zs->zsl,score,ele);
1209+
serverAssert(dictAdd(zs->dict,ele,&node->score) == DICT_OK);
1210+
zzlNext(zl,&eptr,&sptr);
1211+
}
12101212
}
1211-
1213+
12121214
zfree(zobj->m_ptr);
12131215
zobj->m_ptr = zs;
12141216
zobj->encoding = OBJ_ENCODING_SKIPLIST;

0 commit comments

Comments
 (0)