Skip to content

Commit

Permalink
Merge pull request #52 from uno20001/fix_ll_extend
Browse files Browse the repository at this point in the history
linked list: fix ll_extend bug
  • Loading branch information
pobrn authored Oct 15, 2020
2 parents f17af54 + 9139a93 commit df1c64f
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 df1c64f

Please sign in to comment.