Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

按键删除 #7

Open
mandy-yan opened this issue Dec 4, 2019 · 9 comments
Open

按键删除 #7

mandy-yan opened this issue Dec 4, 2019 · 9 comments

Comments

@mandy-yan
Copy link

请问void button_stop(struct Button* handle)这个函数, 在哪将传入的按键删除了, 压根都没看到这个逻辑..

@sj13757790563
Copy link
Contributor

只是把这个按键句柄从链表中移除.这样在按键处理函数中就不会涉及到这个 按键了.内存是仍然占用的.

@mandy-yan
Copy link
Author

mandy-yan commented Dec 5, 2019 via email

@sj13757790563
Copy link
Contributor

我讲不清除,也许下面的图片容易理解.
1
2

@sj13757790563
Copy link
Contributor

curr 在初始化时 指向 head_handle,随后指向了输入的handle中的next字段.我只能这么描述了,或者作者可以讲的更清楚一些

@0x1abin
Copy link
Owner

0x1abin commented Dec 16, 2019

Hi

  1. 这段链表删除是引用 Linus Torvalds 安利的利用二级指针删除单向链表操作
    详见:
    https://coolshell.cn/articles/8990.html

  2. 没在函数内释放内存是因为考虑在一些单片机平台上没有内存管理模块,所以留给开发者自己处理。

@Glacierty
Copy link
Contributor

Glacierty commented Aug 17, 2021

这里二级指针的应用确实很巧妙,看了半天感觉还是一知半解,画了个流程图,应该可以帮助大家理解。另外,在释放内存的后面我加了一句return;这样做效率应该更高吧。
image

@Mshrimp
Copy link

Mshrimp commented Mar 8, 2022

请问这些流程图,是通过什么软件绘制的呢?学习一下,多谢!

@KemGong
Copy link

KemGong commented Mar 20, 2023

请问这些流程图,是通过什么软件绘制的呢?学习一下,多谢!

draw.io

@Glacierty
Copy link
Contributor

Glacierty commented Mar 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants