提交 73dba84e 编写于 作者: Y YuQing

uniq_skiplist_grow set prev link correctly

上级 e4a5cadf
......@@ -228,15 +228,18 @@ static void test_reverse_iterator()
{
UniqSkiplistNode *node;
int v;
int count;
int *value;
v = 21;
printf("test_reverse_iterator\n");
count = 0;
v = 2;
node = uniq_skiplist_find_ge_node(sl, &v);
if (node != NULL) {
while (node != sl->top) {
value = (int *)node->data;
printf("value: %d\n", *value);
node = (UniqSkiplistNode *)LEVEL0_DOUBLE_CHAIN_PREV_LINK(node);
printf("value[%d]: %d\n", count++, *value);
node = UNIQ_SKIPLIST_LEVEL0_PREV_NODE(node);
}
}
}
......
......@@ -236,8 +236,13 @@ static int uniq_skiplist_grow(UniqSkiplist *sl)
sl->top_level_index = top_level_index;
if (sl->factory->bidirection) {
LEVEL0_DOUBLE_CHAIN_TAIL(sl) =
LEVEL0_DOUBLE_CHAIN_PREV_LINK(old_top);
if (top->links[0] != sl->factory->tail) { //not empty
LEVEL0_DOUBLE_CHAIN_PREV_LINK(top->links[0]) = top;
LEVEL0_DOUBLE_CHAIN_TAIL(sl) =
LEVEL0_DOUBLE_CHAIN_PREV_LINK(old_top);
} else {
LEVEL0_DOUBLE_CHAIN_TAIL(sl) = sl->top;
}
}
UNIQ_SKIPLIST_FREE_MBLOCK_OBJECT(sl, old_top_level_index, old_top);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册