LIST_FOR_EACH_ENTRY_SAFE

포스트: 1
Tags

Posts

1 post

[Linux][Kernel] list_for_each_entry_safe() vs list_for_each_entry()

Guillermo Austin Kim|2018년 8월 13일

이번에는 list_for_each_entry_safe()와 list_for_each_entry() 매크로 함수 차이점에 대해서 살펴봅시다.둘 다 리눅스 커널에서 굉장히 많이 쓰는 함수이니 동작을 잘 알아두면 좋습니다. list_for_each_entry_safe() 함수 구현부는 다음과 같습니다.#define list_for_each_entry_safe(pos, n, head, member) \ for (pos = list_first_entry(head, typeof(*pos), member), \ n = list_next_entry(pos, member); \ &pos->member != (head); \ pos = n, n = list_next_entry