8
In the comments of linux/list.h it is written that:
- On using
list_del_entry: Note:list_emptyon entry does not return true after this, the entry is in an undefined state. - For
list_del: This is only for internal list manipulation where we know the prev/next entries already!
So, how would I safely remove an object from linked list and make sure that list_empty is functional or make sure that next linked list node deletion is correct?
This is my implementation currently:
struct kool_list{
int to;
struct list_head list;
int from;
};
struct kool_list *tmp;
struct list_head *pos, *q;
struct kool_list mylist;
list_for_each_safe(pos, q, &mylist.list){
tmp= list_entry(pos, struct kool_list, list);
printf("freeing item to= %d from= %d\n", tmp->to, tmp->from);
list_del(pos);
free(tmp);
}