From 034496c83ebabcd1e32f9fd497edda4909553e30 Mon Sep 17 00:00:00 2001 From: Glacierty Date: Tue, 17 Aug 2021 19:34:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E9=AB=98=E9=93=BE=E8=A1=A8=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=95=88=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 如果不加这一语句,那删除需要遍历整个链表,直到找到尾指针才会退出,虽然时间固定,但是降低了效率,加一个return;可以解决这个问题 --- multi_button.c | 1 + 1 file changed, 1 insertion(+) diff --git a/multi_button.c b/multi_button.c index 1b24854..ff16515 100644 --- a/multi_button.c +++ b/multi_button.c @@ -179,6 +179,7 @@ void button_stop(struct Button* handle) if (entry == handle) { *curr = entry->next; // free(entry); + return; } else curr = &entry->next; }