Skip to content

Commit 16ed6a7

Browse files
author
思也
committed
避免elem的next不为空导致的插入一个链表而非结点
1 parent e0e4e68 commit 16ed6a7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

c-cpp/06_linkedlist/single_list.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ void insert(struct single_list **prev, struct single_list *elem)
3131
if (!prev)
3232
return;
3333

34-
if (*prev)
35-
elem->next = *prev;
34+
elem->next = *prev;
3635
*prev = elem;
3736
}
3837

0 commit comments

Comments
 (0)