Skip to content

Commit

Permalink
list: don't splice empty lists onto the head.
Browse files Browse the repository at this point in the history
fixes bug #56

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
  • Loading branch information
asalkeld committed Mar 7, 2013
1 parent 2125310 commit c77c0a9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions include/qb/qblist.h
Expand Up @@ -157,11 +157,13 @@ static inline void qb_list_splice(struct qb_list_head *list,
struct qb_list_head *last = list->prev;
struct qb_list_head *at = head->next;

first->prev = head;
head->next = first;
if (!qb_list_empty(list)) {
first->prev = head;
head->next = first;

last->next = at;
at->prev = last;
last->next = at;
at->prev = last;
}
}

/**
Expand All @@ -176,11 +178,13 @@ static inline void qb_list_splice_tail(struct qb_list_head *list,
struct qb_list_head *last = list->prev;
struct qb_list_head *at = head;

first->prev = head->prev;
head->prev->next = first;
if (!qb_list_empty(list)) {
first->prev = head->prev;
head->prev->next = first;

last->next = at;
at->prev = last;
last->next = at;
at->prev = last;
}
}

/**
Expand Down

0 comments on commit c77c0a9

Please sign in to comment.