Skip to content

Commit

Permalink
linked list: fix ll_extend bug
Browse files Browse the repository at this point in the history
  • Loading branch information
uno20001 committed Jul 23, 2020
1 parent 2ba2258 commit 9139a93
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ EXPORT struct ll *ll_extend(struct ll *list, struct ll *other)
if (!other)
return list;

LL_NEXT(LL_TAIL(list)) = LL_HEAD(other);
if (!LL_IS_EMPTY(other)) {
LL_NEXT(LL_TAIL(list)) = LL_HEAD(other);
LL_PREV(LL_HEAD(other)) = LL_TAIL(list);
LL_TAIL(list) = LL_TAIL(other);
}


free(other);

Expand Down

0 comments on commit 9139a93

Please sign in to comment.