summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Stancliff <matt@genges.com>2014-11-13 16:12:44 -0500
committerMatt Stancliff <matt@genges.com>2014-12-23 09:31:03 -0500
commit1dfcd75ae36f5f7bea86893c391ea863cd32dee9 (patch)
tree77a664d7954d6a5184225633d6b4c722f27fbd8a
parent53b1ee34ddba1446d81f2ce07c402db271a94674 (diff)
downloadredis-1dfcd75ae36f5f7bea86893c391ea863cd32dee9.tar.gz
Fix ziplist test for pop()
The previous test wasn't returning the new ziplist, so the test was invalid. Now the test works properly. These problems were simultaenously discovered in #2154 and that PR also had an additional fix we included here.
-rw-r--r--src/ziplist.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ziplist.c b/src/ziplist.c
index 7e8823f5a..5ee71d31b 100644
--- a/src/ziplist.c
+++ b/src/ziplist.c
@@ -1014,7 +1014,7 @@ static void stress(int pos, int num, int maxsize, int dnum) {
}
}
-static void pop(unsigned char *zl, int where) {
+static unsigned char *pop(unsigned char *zl, int where) {
unsigned char *p, *vstr;
unsigned int vlen;
long long vlong;
@@ -1034,7 +1034,7 @@ static void pop(unsigned char *zl, int where) {
}
printf("\n");
- ziplistDeleteRange(zl,-1,1);
+ return ziplistDelete(zl,&p);
} else {
printf("ERROR: Could not pop\n");
exit(1);
@@ -1099,16 +1099,16 @@ int ziplistTest(int argc, char **argv) {
zl = createList();
ziplistRepr(zl);
- pop(zl,ZIPLIST_TAIL);
+ zl = pop(zl,ZIPLIST_TAIL);
ziplistRepr(zl);
- pop(zl,ZIPLIST_HEAD);
+ zl = pop(zl,ZIPLIST_HEAD);
ziplistRepr(zl);
- pop(zl,ZIPLIST_TAIL);
+ zl = pop(zl,ZIPLIST_TAIL);
ziplistRepr(zl);
- pop(zl,ZIPLIST_TAIL);
+ zl = pop(zl,ZIPLIST_TAIL);
ziplistRepr(zl);
printf("Get element at index 3:\n");