Commit 79226cb9 authored by antirez's avatar antirez
Browse files

adlist: fix listJoin() to handle empty lists.

parent 67987369
...@@ -345,8 +345,14 @@ void listRotate(list *list) { ...@@ -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. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment