Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5ff00ac8
Commit
5ff00ac8
authored
Feb 24, 2015
by
Salvatore Sanfilippo
Browse files
Merge pull request #2401 from mattsta/fix/quicklist/pop
Fix quicklist Pop()
parents
fc365a3a
552e5908
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/quicklist.c
View file @
5ff00ac8
...
...
@@ -1372,7 +1372,7 @@ REDIS_STATIC void *_quicklistSaver(unsigned char *data, unsigned int sz) {
unsigned char *vstr;
if (data) {
vstr = zmalloc(sz);
memcpy(
data, vstr
, sz);
memcpy(
vstr, data
, sz);
return vstr;
}
return NULL;
...
...
@@ -1757,7 +1757,8 @@ int quicklistTest(int argc, char *argv[]) {
TEST("pop 1 string from 1") {
quicklist *ql = quicklistNew(-2, options[_i]);
quicklistPushHead(ql, genstr("hello", 331), 32);
char *populate = genstr("hello", 331);
quicklistPushHead(ql, populate, 32);
unsigned char *data;
unsigned int sz;
long long lv;
...
...
@@ -1765,6 +1766,9 @@ int quicklistTest(int argc, char *argv[]) {
quicklistPop(ql, QUICKLIST_HEAD, &data, &sz, &lv);
assert(data != NULL);
assert(sz == 32);
if (strcmp(populate, (char *)data))
ERR("Pop'd value (%.*s) didn't equal original value (%s)", sz,
data, populate);
zfree(data);
ql_verify(ql, 0, 0, 0, 0);
quicklistRelease(ql);
...
...
@@ -1797,6 +1801,9 @@ int quicklistTest(int argc, char *argv[]) {
assert(ret == 1);
assert(data != NULL);
assert(sz == 32);
if (strcmp(genstr("hello", 499 - i), (char *)data))
ERR("Pop'd value (%.*s) didn't equal original value (%s)",
sz, data, genstr("hello", 499 - i));
zfree(data);
}
ql_verify(ql, 0, 0, 0, 0);
...
...
@@ -1816,6 +1823,10 @@ int quicklistTest(int argc, char *argv[]) {
assert(ret == 1);
assert(data != NULL);
assert(sz == 32);
if (strcmp(genstr("hello", 499 - i), (char *)data))
ERR("Pop'd value (%.*s) didn't equal original value "
"(%s)",
sz, data, genstr("hello", 499 - i));
zfree(data);
} else {
assert(ret == 0);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment