mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
adlist: fix listJoin() to handle empty lists.
This commit is contained in:
parent
6798736909
commit
79226cb9fa
@ -345,8 +345,14 @@ void listRotate(list *list) {
|
|||||||
/* Add all the elements of the list 'o' at the end of the
|
/* Add all the elements of the list 'o' at the end of the
|
||||||
* list 'l'. The list 'other' remains empty but otherwise valid. */
|
* list 'l'. The list 'other' remains empty but otherwise valid. */
|
||||||
void listJoin(list *l, list *o) {
|
void listJoin(list *l, list *o) {
|
||||||
l->tail->next = o->head;
|
if (o->head)
|
||||||
o->head->prev = l->tail;
|
o->head->prev = l->tail;
|
||||||
|
|
||||||
|
if (l->tail)
|
||||||
|
l->tail->next = o->head;
|
||||||
|
else
|
||||||
|
l->head = o->head;
|
||||||
|
|
||||||
l->tail = o->tail;
|
l->tail = o->tail;
|
||||||
|
|
||||||
/* Setup other as an empty list. */
|
/* Setup other as an empty list. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user