The following code can create a quicklist with 5 adjacent small nodes, which is waste of memory.
TEST("adjacent small nodes") {
unsigned char *big_string = zmalloc(packed_threshold);
randstring(big_string, packed_threshold);
quicklist *ql = quicklistNew(-2, 0);
quicklistPushHead(ql, "1", 1);
quicklistPushHead(ql, big_string, packed_threshold);
quicklistPushHead(ql, "1", 1);
quicklistPushHead(ql, big_string, packed_threshold);
quicklistPushHead(ql, "1", 1);
quicklistPushHead(ql, big_string, packed_threshold);
quicklistPushHead(ql, "1", 1);
quicklistPushHead(ql, big_string, packed_threshold);
quicklistPushHead(ql, "1", 1);
quicklistDelRange(ql, 1, 1);
quicklistDelRange(ql, 2, 1);
quicklistDelRange(ql, 3, 1);
quicklistDelRange(ql, 4, 1);
assert(ql->count == 5);
quicklistIter *iter = quicklistGetIterator(ql, AL_START_HEAD);
quicklistEntry entry;
while (quicklistNext(iter, &entry)) {
assert(entry.longval == 1);
}
zfree(big_string);
quicklistReleaseIterator(iter);
quicklistRelease(ql);
}