Programming/Linux_Kernel
kernel list 항목 삭제
decdream
2012. 2. 28. 15:52
항목을 삭제할때 얻는 item(객체) 은
list_for_each_entry 가 아닌 list_for_each_entry_safe 로 얻은 item 이어야 한다.
*자세한 설명은 kernel document 참고
ex)
#include <linux/list.h>
struct packet {
u8 data_1;
u8 data_2;
struct list_head p_packet_list;
};
LIST_HEAD(g_packet_list);
void func()
{
struct packet* p_pkt, *scratch;
...
list_for_each_entry_safe(p_pkt, scratch, &g_packet_list, p_packet_list) {
list_del(&p_pkt->p_packet_list);
kfree(p_pkt);
}
}
list 의 사용법에 대해서는 아래 사이트에 좋은 예제가 있다.
http://blog.naver.com/kkn2988?Redirect=Log&logNo=143977338